Skip to content

Commit

Permalink
build: use image_builder in armv7m7 based projects
Browse files Browse the repository at this point in the history
JIRA: CI-494
  • Loading branch information
nalajcie committed Sep 24, 2024
1 parent fe0b4c4 commit b835f1c
Show file tree
Hide file tree
Showing 12 changed files with 178 additions and 166 deletions.
63 changes: 9 additions & 54 deletions _targets/armv7m7/imxrt105x/build.project
Original file line number Diff line number Diff line change
Expand Up @@ -36,63 +36,22 @@ export PORTS_AZURE_SDK=n
#
# Platform dependent parameters
#
SIZE_PAGE=$((0x200))
PAGE_MASK=$((0xfffffe00))
export SIZE_PAGE=$((0x200))

#
# Project specific build
#

BOOT_DEVICE="flash0"
NAME_USER_SCRIPT="user.plo"
OFFS_USER_SCRIPT=$((0x11000))
MAGIC_USER_SCRIPT=$((0xdabaabad))
KERNEL_OFFS=$((0x12000))
export BOOT_DEVICE="flash0"
export MAGIC_USER_SCRIPT=dabaabad


# Physical kernel address
KERNEL_PHBASE=$((0x0)) # itcm start address
KERNEL_PHOFFS=$((0x0))
export KERNEL_PHADDR=$(printf "%08x" $((KERNEL_PHBASE + KERNEL_PHOFFS)))
KERNEL_PHADDR=$(printf "%08x" $((KERNEL_PHBASE + KERNEL_PHOFFS)))
export KERNEL_PHADDR

# All data/code maps need to be cacheable to allow unaligned accesses

# Pre-init script is launched before user script
PREINIT_SCRIPT=(
"map itcm 0x0 0x28000 rwxcb"
"map dtcm 0x20000000 0x20048000 rwcb"
"map ocram 0x20200000 0x20220000 rwxcb"
"map xip1 0x60000000 0x60800000 rxcb"
"map io 0x40000000 0x50000000 rw"
"phfs usb0 1.2 phoenixd"
"phfs flash0 2.0 raw"
"console 0.0")


# Production user script contains applications to run Phoenix-RTOS
USER_SCRIPT=(
"kernel ${BOOT_DEVICE}"
"app ${BOOT_DEVICE} -x dummyfs xip1 dtcm"
"app ${BOOT_DEVICE} -x imxrt-multi xip1 dtcm;io"
"app ${BOOT_DEVICE} -x psh xip1 dtcm"
"wait 2000"
"go!")


# Example of user dev script which call remotely script
DEV_USER_SCRIPT=(
"echo on"
"wait 3000"
"call usb0 script-${TARGET_FAMILY}-${TARGET_SUBFAMILY}-dev.plo 5a5aa5a5")


REMOTE_USER_SCRIPT=(
"5a5aa5a5"
"kernel usb0"
"app usb0 -x dummyfs ocram dtcm"
"app usb0 -x imxrt-multi itcm ocram"
"app usb0 -x psh ocram dtcm"
"go!")


b_build_project() {
Expand All @@ -105,7 +64,8 @@ b_build_target() {
b_log "Building $TARGET project"
b_log "Building phoenix-rtos-loader"

b_mkscript_preinit
image_builder.py script --nvm "$NVM_CONFIG" --script "$PLO_SCRIPT_PREINIT" --out script.plo
RAM_SCRIPT=1 image_builder.py script --nvm "$NVM_CONFIG" --script "$PLO_SCRIPT_PREINIT" --out script-ram.plo

make -C plo all

Expand All @@ -115,13 +75,8 @@ b_build_target() {


b_image_target() {
b_mkscript_user "${USER_SCRIPT[@]}"
b_prod_image

# TODO: Fix b_dev_image overwriting user.plo created by b_prod_image
cp "$PLO_SCRIPT_DIR/$NAME_USER_SCRIPT" "${PREFIX_BOOT}"

b_dev_image
image_builder.py -v partition --nvm "$NVM_CONFIG" --name user --script "$PLO_SCRIPT_USER"
image_builder.py -v disk --nvm "$NVM_CONFIG" --part "plo=${PREFIX_PROG_STRIPPED}plo-${TARGET_FAMILY}-${TARGET_SUBFAMILY}.img" --out "phoenix.disk"
}


Expand Down
12 changes: 12 additions & 0 deletions _targets/armv7m7/imxrt105x/nvm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# example NVM config - based on EVK board
flash0:
# external qspi flash - is25wp064a (64Mbit)
size: 0x800000 # 8 MB
block_size: 0x1000
padding_byte: 0xff
partitions:
- name: plo
offs: 0x0
- name: user
offs: 0x11000
# if size not set - last non-virtual partition will be extnded to the end of flash
22 changes: 22 additions & 0 deletions _targets/armv7m7/imxrt105x/preinit.plo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
size: 0x1000
is_relative: False

contents:
# NOTE: All data/code maps need to be cacheable to allow unaligned accesses
- map itcm 0x0 0x28000 rwxcb
- map dtcm 0x20000000 0x20048000 rwcb
- map ocram 0x20200000 0x20220000 rwxcb
- map xip1 0x60000000 0x60800000 rxcb
- map io 0x40000000 0x50000000 rw
- phfs usb0 1.2 phoenixd
- phfs flash0 2.0 raw
- console 0.0

- if: '{{ not(env.RAM_SCRIPT) | default(false) }}'
action: call
set_base: True
device: '{{ env.BOOT_DEVICE }}'
filename: user.plo
offset: '{{ nvm[env.BOOT_DEVICE].user.offs }}'
target_magic: '{{ env.MAGIC_USER_SCRIPT }}'

13 changes: 13 additions & 0 deletions _targets/armv7m7/imxrt105x/user.plo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# kernel + initrd
magic: '{{ env.MAGIC_USER_SCRIPT }}'
size: 0x1000
is_relative: True

contents:
- kernel {{ env.BOOT_DEVICE }}
- app {{ env.BOOT_DEVICE }} -x dummyfs xip1 dtcm
- app {{ env.BOOT_DEVICE }} -x imxrt-multi xip1 dtcm;io
- app {{ env.BOOT_DEVICE }} -x psh xip1 dtcm
#WARN: no flash driver is being run
- wait 2000
- go!
71 changes: 9 additions & 62 deletions _targets/armv7m7/imxrt106x/build.project
Original file line number Diff line number Diff line change
Expand Up @@ -36,70 +36,21 @@ export PORTS_AZURE_SDK=n
#
# Platform dependent parameters
#
SIZE_PAGE=$((0x200))
PAGE_MASK=$((0xfffffe00))

export SIZE_PAGE=$((0x200))

#
# Project specific build
#

BOOT_DEVICE="flash1"
NAME_USER_SCRIPT="user.plo"
OFFS_USER_SCRIPT=$((0x11000))
MAGIC_USER_SCRIPT=$((0xdabaabad))
KERNEL_OFFS=$((0x12000))
export BOOT_DEVICE="flash1"
export MAGIC_USER_SCRIPT=dabaabad


# Physical kernel address
KERNEL_PHBASE=$((0x0)) # itcm start address
KERNEL_PHOFFS=$((0x0))
export KERNEL_PHADDR=$(printf "%08x" $((KERNEL_PHBASE + KERNEL_PHOFFS)))

# All data/code maps need to be cacheable to allow unaligned accesses

# Pre-init script is launched before user script
PREINIT_SCRIPT=(
"map itcm 0x0 0x28000 rwxcb"
"map dtcm 0x20000000 0x20058000 rwcb"
"map ocram2 0x20200000 0x20280000 rwxcb"
"map aips14 0x40000000 0x40400000 rws"
"map aips5 0x42000000 0x42100000 rws"
"map xip2 0x60000000 0x64000000 rxcb"
"map xip1 0x70000000 0x70400000 rxcb"
"phfs usb0 1.2 phoenixd"
"phfs flash0 2.0 raw"
"phfs flash1 2.1 raw"
"console 0.0")


# Production user script contains applications to run Phoenix-RTOS
USER_SCRIPT=(
"kernel ${BOOT_DEVICE}"
"app ${BOOT_DEVICE} -x dummyfs xip1 ocram2"
"app ${BOOT_DEVICE} -x imxrt-multi xip1 ocram2;aips14;aips5"
"app ${BOOT_DEVICE} -x psh xip1 ocram2"
"app ${BOOT_DEVICE} imxrt-flash ocram2 ocram2;aips14"
"wait 2000"
"go!")


# Example of user dev script which call remotely script
DEV_USER_SCRIPT=(
"echo on"
"wait 3000"
"call usb0 script-${TARGET_FAMILY}-${TARGET_SUBFAMILY}-dev.plo 5a5aa5a5")


REMOTE_USER_SCRIPT=(
"5a5aa5a5"
"kernel usb0"
"app usb0 -x dummyfs ocram2 ocram2"
"app usb0 -x imxrt-multi itcm dtcm"
"app usb0 -x psh ocram2 ocram2"
"copy usb0 imxrt-flash flash1 0x15000 0"
"app flash1 imxrt-flash ocram2 dtcm"
"go!")
KERNEL_PHADDR=$(printf "%08x" $((KERNEL_PHBASE + KERNEL_PHOFFS)))
export KERNEL_PHADDR


b_build_project() {
Expand All @@ -112,7 +63,8 @@ b_build_target() {
b_log "Building $TARGET project"
b_log "Building phoenix-rtos-loader"

b_mkscript_preinit
image_builder.py script --nvm "$NVM_CONFIG" --script "$PLO_SCRIPT_PREINIT" --out script.plo
RAM_SCRIPT=1 image_builder.py script --nvm "$NVM_CONFIG" --script "$PLO_SCRIPT_PREINIT" --out script-ram.plo

make -C plo all

Expand All @@ -122,13 +74,8 @@ b_build_target() {


b_image_target() {
b_mkscript_user "${USER_SCRIPT[@]}"
b_prod_image

# TODO: Fix b_dev_image overwriting user.plo created by b_prod_image
cp "$PLO_SCRIPT_DIR/$NAME_USER_SCRIPT" "${PREFIX_BOOT}"

b_dev_image
image_builder.py -v partition --nvm "$NVM_CONFIG" --name user --script "$PLO_SCRIPT_USER"
image_builder.py -v disk --nvm "$NVM_CONFIG" --name flash1 --part "plo=${PREFIX_PROG_STRIPPED}plo-${TARGET_FAMILY}-${TARGET_SUBFAMILY}.img" --out "phoenix.disk"
}


Expand Down
19 changes: 19 additions & 0 deletions _targets/armv7m7/imxrt106x/nvm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# example NVM config - based on EVK board
flash0:
# internal flash - W25Q32JV (32Mbit)
# not used currently
size: 0x400000 # 4 MB
block_size: 0x1000
padding_byte: 0xff

flash1:
# external qspi flash - is25wp064a (64Mbit)
size: 0x800000 # 8 MB
block_size: 0x1000
padding_byte: 0xff
partitions:
- name: plo
offs: 0x0
- name: user
offs: 0x11000
# if size not set - last non-virtual partition will be extnded to the end of flash
25 changes: 25 additions & 0 deletions _targets/armv7m7/imxrt106x/preinit.plo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
size: 0x1000
is_relative: False

contents:
# NOTE: All data/code maps need to be cacheable to allow unaligned accesses
- map itcm 0x0 0x28000 rwxcb
- map dtcm 0x20000000 0x20058000 rwcb
- map ocram2 0x20200000 0x20280000 rwxcb
- map aips14 0x40000000 0x40400000 rws
- map aips5 0x42000000 0x42100000 rws
- map xip2 0x60000000 0x64000000 rxcb
- map xip1 0x70000000 0x70400000 rxcb
- phfs usb0 1.2 phoenixd
- phfs flash0 2.0 raw
- phfs flash1 2.1 raw
- console 0.0

- if: '{{ not(env.RAM_SCRIPT) | default(false) }}'
action: call
set_base: True
device: '{{ env.BOOT_DEVICE }}'
filename: user.plo
offset: '{{ nvm[env.BOOT_DEVICE].user.offs }}'
target_magic: '{{ env.MAGIC_USER_SCRIPT }}'

13 changes: 13 additions & 0 deletions _targets/armv7m7/imxrt106x/user.plo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# kernel + initrd
magic: '{{ env.MAGIC_USER_SCRIPT }}'
size: 0x1000
is_relative: True

contents:
- kernel {{ env.BOOT_DEVICE }}
- app {{ env.BOOT_DEVICE }} -x dummyfs xip1 ocram2
- app {{ env.BOOT_DEVICE }} -x imxrt-multi xip1 ocram2;aips14;aips5
- app {{ env.BOOT_DEVICE }} -x psh xip1 ocram2
- app {{ env.BOOT_DEVICE }} imxrt-flash ocram2 ocram2;aips14
- wait 2000
- go!
59 changes: 9 additions & 50 deletions _targets/armv7m7/imxrt117x/build.project
Original file line number Diff line number Diff line change
Expand Up @@ -34,64 +34,23 @@ export PORTS_CURL=n
#
# Platform dependent parameters
#
SIZE_PAGE=$((0x200))
PAGE_MASK=$((0xfffffe00))
export SIZE_PAGE=$((0x200))


#
# Project specific build
#

export BOOT_DEVICE="flash0"
export MAGIC_USER_SCRIPT=dabaabad
BOOT_DEVICE="flash0"
NAME_USER_SCRIPT="user.plo"
OFFS_USER_SCRIPT=$((0x11000))
MAGIC_USER_SCRIPT=$((0xdabaabad))
KERNEL_OFFS=$((0x12000))


# Physical kernel address
KERNEL_PHBASE=$((0x0)) # itcm start address
KERNEL_PHOFFS=$((0x0))
export KERNEL_PHADDR=$(printf "%08x" $((KERNEL_PHBASE + KERNEL_PHOFFS)))

# All data/code maps need to be cacheable to allow unaligned accesses

# Pre-init script is launched before user script
PREINIT_SCRIPT=(
"map itcm 0x0 0x40000 rwxcb"
"map dtcm 0x20000000 0x20028000 rwcb"
"map ocram2 0x202c0000 0x20340000 rwxcb"
"map aips14 0x40000000 0x41000000 rws"
"map aips5 0x42000000 0x42100000 rws"
"map xip1 0x30000000 0x30400000 rxcb"
"phfs usb0 1.2 phoenixd"
"phfs flash0 2.0 raw"
"console 0.0")


# Production user script contains applications to run Phoenix-RTOS
USER_SCRIPT=(
"kernel ${BOOT_DEVICE}"
"app ${BOOT_DEVICE} -x dummyfs xip1 ocram2"
"app ${BOOT_DEVICE} -x imxrt-multi xip1 ocram2;aips14;aips5"
"app ${BOOT_DEVICE} -x psh xip1 ocram2"
"wait 2000"
"go!")

# Example of user dev script which call remotely script
DEV_USER_SCRIPT=(
"echo on"
"wait 3000"
"call usb0 script-${TARGET_FAMILY}-${TARGET_SUBFAMILY}-dev.plo 5a5aa5a5")


REMOTE_USER_SCRIPT=(
"5a5aa5a5"
"kernel usb0"
"app usb0 -x dummyfs ocram2 ocram2"
"app usb0 -x imxrt-multi itcm dtcm"
"app usb0 -x psh ocram2 ocram2"
"go!")
KERNEL_PHADDR=$(printf "%08x" $((KERNEL_PHBASE + KERNEL_PHOFFS)))
export KERNEL_PHADDR


b_build_project() {
Expand All @@ -104,7 +63,8 @@ b_build_target() {
b_log "Building $TARGET project"
b_log "Building phoenix-rtos-loader"

b_mkscript_preinit
image_builder.py script --nvm "$NVM_CONFIG" --script "$PLO_SCRIPT_PREINIT" --out script.plo
RAM_SCRIPT=1 image_builder.py script --nvm "$NVM_CONFIG" --script "$PLO_SCRIPT_PREINIT" --out script-ram.plo

make -C plo all

Expand All @@ -114,9 +74,8 @@ b_build_target() {


b_image_target() {
b_mkscript_user "${USER_SCRIPT[@]}"
b_prod_image
b_dev_image
image_builder.py -v partition --nvm "$NVM_CONFIG" --name user --script "$PLO_SCRIPT_USER"
image_builder.py -v disk --nvm "$NVM_CONFIG" --part "plo=${PREFIX_PROG_STRIPPED}plo-${TARGET_FAMILY}-${TARGET_SUBFAMILY}.img" --out "phoenix.disk"
}


Expand Down
Loading

0 comments on commit b835f1c

Please sign in to comment.