Skip to content

Commit

Permalink
build: use image_builder in armv7m4 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 16404c3 commit ae023f2
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 45 deletions.
59 changes: 14 additions & 45 deletions _targets/armv7m4/stm32l4x6/build.project
Original file line number Diff line number Diff line change
Expand Up @@ -33,57 +33,22 @@ export PORTS_CURL=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=$((0xc800))
MAGIC_USER_SCRIPT=$((0xdabaabad))
KERNEL_OFFS=$((0xd000))
export BOOT_DEVICE="flash0"
export MAGIC_USER_SCRIPT=dabaabad


# Physical kernel address
KERNEL_PHBASE=$((0x08000000)) # flash0 start address
KERNEL_PHOFFS=$KERNEL_OFFS
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 flash0 0x08000000 0x08080000 rxcb"
"map flash1 0x08080000 0x08100000 rxcb"
"map ram 0x20000000 0x20050000 rwxcb"
"map io 0x40000000 0x60000000 rw"
"map otp 0x1fff0000 0x20000000 rw"
"phfs flash0 2.0 raw"
"phfs flash1 2.1 raw"
"phfs ramdev 4.0 raw"
"console 0.1")


# Production user script contains applications to run Phoenix-RTOS
USER_SCRIPT=(
"kernelimg ${BOOT_DEVICE}"
"app ${BOOT_DEVICE} -x stm32l4-multi flash0 ram;io;otp"
"app ${BOOT_DEVICE} -x psh flash0 ram"
"wait 2000"
"go!")


# Example of user dev script which call remotely script
DEV_USER_SCRIPT=(
"echo on"
"wait 3000")


REMOTE_USER_SCRIPT=("5a5aa5a5")
KERNEL_PHOFFS=$(image_builder.py query --nvm "$NVM_CONFIG" '{{ nvm.flash0.kernel.offs }}')
KERNEL_PHADDR=$(printf "%08x" $((KERNEL_PHBASE + KERNEL_PHOFFS)))
export KERNEL_PHADDR


b_build_project() {
Expand All @@ -96,16 +61,20 @@ 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

b_log "Creating kernel binary image"
KERNEL_ELF="phoenix-${TARGET_FAMILY}-${TARGET_SUBFAMILY}.elf"
${CROSS}objcopy "${PREFIX_PROG_STRIPPED}${KERNEL_ELF}" -O binary "${PREFIX_PROG_STRIPPED}${KERNEL_ELF/.elf/.bin}"
}


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" --name flash0 --part "plo=${PREFIX_PROG_STRIPPED}plo-${TARGET_FAMILY}-${TARGET_SUBFAMILY}.img" --out "phoenix.disk"
}

b_test_target() {
Expand Down
16 changes: 16 additions & 0 deletions _targets/armv7m4/stm32l4x6/nvm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
flash0:
# internal flash - 2 banks 512 kB - assume the target image can't exceed one bank
size: 0x80000 # 512 kB
block_size: 0x100 # program page size
padding_byte: 0xff
partitions:
- name: plo
offs: 0x0
- name: user
offs: 0xc800
# if size not set - last non-virtual partition will be extnded to the end of flash

# virtual offset [user.offs] + [user.script.size]
- name: kernel
offs: 0xd000
virtual: True
22 changes: 22 additions & 0 deletions _targets/armv7m4/stm32l4x6/preinit.plo.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
size: 0x200
is_relative: False

contents:
# NOTE: All data/code maps need to be cacheable to allow unaligned accesses
- map flash0 0x08000000 0x08080000 rxcb
- map flash1 0x08080000 0x08100000 rxcb
- map ram 0x20000000 0x20050000 rwxcb
- map io 0x40000000 0x60000000 rw
- map otp 0x1fff0000 0x20000000 rw
- phfs flash0 2.0 raw
- phfs flash1 2.1 raw
- phfs ramdev 4.0 raw
- console 0.1
- 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 }}'

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

contents:
- kernelimg {{ env.BOOT_DEVICE }}
- app {{ env.BOOT_DEVICE }} -x stm32l4-multi flash0 ram;io;otp
- app {{ env.BOOT_DEVICE }} -x psh flash0 ram
- wait 2000
- go!

0 comments on commit ae023f2

Please sign in to comment.