# Porting for RK3566 Radxa CM3

**URL:** <https://hub.mender.io/t/porting-for-rk3566-radxa-cm3/5133>\
**Category:** Board Integrations\
**Tags:** rockchip, rk3566, radxa, radxa-cm3\
**Created:** [July 19, 2022, 12:17pm UTC](https://hub.mender.io/t/porting-for-rk3566-radxa-cm3/5133 "2022-07-19T12:17:33Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![milp](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@milp](https://hub.mender.io/u/milp)\
**Post date:** [July 19, 2022, 12:17pm UTC](https://hub.mender.io/t/porting-for-rk3566-radxa-cm3/5133/1 "2022-07-19T12:17:33Z")

</div>

Hi there,

i am currently working on porting Mender to the RK3566 platform, namely by the use of the Radxa CM3 hardware.

I have adapted the mender-convert project config for the RockPro64 to build U-boot for the RK3566.

However it always gets stuck at ‘Error: “mender\_setup” not defined’

Mender setup is defined in env\_mender.h which is included in env\_default.h so i don’t really understand why it can’t seem to find it.

This is the stacktrace i am facing:

```auto
Call trace:
 PC: [< 00a9d958 >] efi_add_memory_map+0x18/0x210      
 LR: [< 00a0931c >] efi_set_bootdev+0x88/0x118      

Stack:
       [< 00a9d958 >] efi_add_memory_map+0x18/0x210
       [< 00a0931c >] efi_set_bootdev+0x88/0x118
       [< 00a0b214 >] do_load_wrapper+0x40/0x80
       [< 00a3024c >] cmd_auto_complete+0x274/0x4a0
       [< 00a198f4 >] run_list_real+0x53c/0x724
       [< 00a19a98 >] run_list_real+0x6e0/0x724
       [< 00a191e8 >] insert_var_value_sub+0x1dc/0x2c0
       [< 00a196b0 >] run_list_real+0x2f8/0x724
       [< 00a1956c >] run_list_real+0x1b4/0x724
       [< 00a19a98 >] run_list_real+0x6e0/0x724
       [< 00a191a4 >] insert_var_value_sub+0x198/0x2c0
       [< 00a2f770 >] fb_mmc_flash_write+0x59c/0x65c
       [< 00a07dd4 >] source+0x104/0x1d0
       [< 00a07edc >] do_source+0x3c/0x7c
       [< 00a3024c >] cmd_auto_complete+0x274/0x4a0
       [< 00a198f4 >] run_list_real+0x53c/0x724
       [< 00a19a98 >] run_list_real+0x6e0/0x724
       [< 00a191e8 >] insert_var_value_sub+0x1dc/0x2c0
       [< 00a196b0 >] run_list_real+0x2f8/0x724
       [< 00a19a98 >] run_list_real+0x6e0/0x724
       [< 00a191a4 >] insert_var_value_sub+0x198/0x2c0
       [< 00a2f808 >] fb_mmc_flash_write+0x634/0x65c
       [< 00a3024c >] cmd_auto_complete+0x274/0x4a0
       [< 00a198f4 >] run_list_real+0x53c/0x724
       [< 00a1956c >] run_list_real+0x1b4/0x724
       [< 00a1956c >] run_list_real+0x1b4/0x724
       [< 00a19a98 >] run_list_real+0x6e0/0x724
       [< 00a191a4 >] insert_var_value_sub+0x198/0x2c0
       [< 00a2f808 >] fb_mmc_flash_write+0x634/0x65c
       [< 00a3024c >] cmd_auto_complete+0x274/0x4a0
       [< 00a198f4 >] run_list_real+0x53c/0x724
       [< 00a1956c >] run_list_real+0x1b4/0x724
       [< 00a19a98 >] run_list_real+0x6e0/0x724
       [< 00a191a4 >] insert_var_value_sub+0x198/0x2c0
       [< 00a2f808 >] fb_mmc_flash_write+0x634/0x65c
       [< 00a3024c >] cmd_auto_complete+0x274/0x4a0
       [< 00a198f4 >] run_list_real+0x53c/0x724
       [< 00a1956c >] run_list_real+0x1b4/0x724
       [< 00a1956c >] run_list_real+0x1b4/0x724
       [< 00a19a98 >] run_list_real+0x6e0/0x724
       [< 00a191a4 >] insert_var_value_sub+0x198/0x2c0
       [< 00a2f808 >] fb_mmc_flash_write+0x634/0x65c
       [< 00a3024c >] cmd_auto_complete+0x274/0x4a0
       [< 00a198f4 >] run_list_real+0x53c/0x724
       [< 00a1956c >] run_list_real+0x1b4/0x724
       [< 00a19a98 >] run_list_real+0x6e0/0x724
       [< 00a191a4 >] insert_var_value_sub+0x198/0x2c0
       [< 00a2f808 >] fb_mmc_flash_write+0x634/0x65c
       [< 00a3024c >] cmd_auto_complete+0x274/0x4a0
       [< 00a198f4 >] run_list_real+0x53c/0x724
       [< 00a19a98 >] run_list_real+0x6e0/0x724
       [< 00a191a4 >] insert_var_value_sub+0x198/0x2c0
       [< 00a2f808 >] fb_mmc_flash_write+0x634/0x65c
       [< 00a3024c >] cmd_auto_complete+0x274/0x4a0
       [< 00a198f4 >] run_list_real+0x53c/0x724
       [< 00a19a98 >] run_list_real+0x6e0/0x724
       [< 00a191e8 >] insert_var_value_sub+0x1dc/0x2c0
       [< 00a196b0 >] run_list_real+0x2f8/0x724
       [< 00a1956c >] run_list_real+0x1b4/0x724
       [< 00a19a98 >] run_list_real+0x6e0/0x724
       [< 00a191a4 >] insert_var_value_sub+0x198/0x2c0
       [< 00a2f808 >] fb_mmc_flash_write+0x634/0x65c
       [< 00a3024c >] cmd_auto_complete+0x274/0x4a0
       [< 00a198f4 >] run_list_real+0x53c/0x724
       [< 00a19a98 >] run_list_real+0x6e0/0x724
       [< 00a191a4 >] insert_var_value_sub+0x198/0x2c0
       [< 00a2f770 >] fb_mmc_flash_write+0x59c/0x65c
       [< 00a1a140 >] parse_stream_outer+0x664/0x67c
       [< 00a17c20 >] env_get_ulong+0x8/0x40
       [< 00a1a7bc >] reserve_video+0x4/0x2c
       [< 00aa1fa8 >] unflatten_dt_node+0x9c/0x3f4
       [< 00a1aa3c >] initr_jumptable+0x10/0x18
       [< 00a01e00 >] relocation_return+0x4/0x0

```

This is the raw console output during boot:

```auto
U-Boot 2017.09-g693c4cd017e-211223 #stephen (Jan 26 2022 - 11:32:22 +0800)

Model: Radxa CM3 IO
PreSerial: 2, raw, 0xfe660000
DRAM: 4 GiB
Sysmem: init
Relocation Offset: ed349000
Relocation fdt: eb9f9320 - eb9fecc8
CR: M/C/I
Using default environment

failed to find reset-gpios property
dwmmc@fe2b0000: 1, dwmmc@fe2c0000: 2, sdhci@fe310000: 0
Bootdev(atags): mmc 0
MMC0: HS200, 200Mhz
PartType: EFI
No misc partition
boot mode: None
FIT: No fdt blob
No resource partition
No resource partition
Failed to load DTB, ret=-19
Failed to get kernel dtb, ret=-19
io-domain: OK
Model: Radxa CM3 IO
rockchip_set_serialno: could not find efuse/otp device
CLK: (sync kernel. arm: enter 816000 KHz, init 816000 KHz, kernel 0N/A)
  apll 816000 KHz
  dpll 528000 KHz
  gpll 1188000 KHz
  cpll 1000000 KHz
  npll 24000 KHz
  vpll 24000 KHz
  hpll 24000 KHz
  ppll 200000 KHz
  armclk 816000 KHz
  aclk_bus 150000 KHz
  pclk_bus 50000 KHz
  aclk_top_high 300000 KHz
  aclk_top_low 200000 KHz
  hclk_top 150000 KHz
  pclk_top 50000 KHz
  aclk_perimid 300000 KHz
  hclk_perimid 150000 KHz
  pclk_pmu 100000 KHz
No misc partition
Net: No ethernet found.
Hit key to stop autoboot('CTRL+C'): 0
failed to find reset-gpios property

Device 0: unknown device
switch to partitions #0, OK
mmc1 is current device
Scanning mmc 1:1...
Found U-Boot script /boot.scr
reading /boot.scr
3136 bytes read in 2 ms (1.5 MiB/s)
Executing script at 00c00000
Error: "mender_setup" not defined

Boot script loaded from
"Synchronous Abort" handler, esr 0x96000004

    Reason: Exception from a Data abort, from current exception level
    PC = 0000000000a9d958
    LR = 0000000000a0931c
    SP = 00000000eb9f6f60
    ESR_EL2 = 0000000096000004
    Reloc Off = 00000000ed349000

x0 : d5181040d2a00600 x1 : 0000000000000000
x2 : 0000000000000000 x3 : 0000000000000000
x4 : 0000000000000030 x5 : 00000000ebd6f1d0
x6 : 0000000000000000 x7 : 000000000000000a
x8 : 0000000000000044 x9 : 0000000000000008
x10: 00000000ede2ec82 x11: 00000000ebd56e58
x12: 0000000000000002 x13: 0000000000000004
x14: 00000000eb9f920c x15: 0000000000000008
x16: 0000000000000084 x17: 0000000000000032
x18: 00000000eb9ffce8 x19: 0000000000000000
x20: 0000000000000000 x21: 00000000ebd6f1d0
x22: 00000000ede78000 x23: 00000000ebd6f1f0
x24: 0000000000000000 x25: 0000000000000000
x26: 0000000000000000 x27: 0000000000000000
x28: 00000000ebd6f240 x29: 00000000eb9f7140

Call trace:
  PC: [< 00a9d958 >]
  LR: [< 00a0931c >]

Stack:
        [< 00a9d958 >]
        [< 00a0931c >]
        [< 00a0b214 >]
        [< 00a3024c >]
        [< 00a198f4 >]
        [< 00a19a98 >]
        [< 00a191e8 >]
        [< 00a196b0 >]
        [< 00a1956c >]
        [< 00a19a98 >]
        [< 00a191a4 >]
        [< 00a2f770 >]
        [< 00a07dd4 >]
        [< 00a07edc >]
        [< 00a3024c >]
        [< 00a198f4 >]
        [< 00a19a98 >]
        [< 00a191e8 >]
        [< 00a196b0 >]
        [< 00a19a98 >]
        [< 00a191a4 >]
        [< 00a2f808 >]
        [< 00a3024c >]
        [< 00a198f4 >]
        [< 00a1956c >]
        [< 00a1956c >]
        [< 00a19a98 >]
        [< 00a191a4 >]
        [< 00a2f808 >]
        [< 00a3024c >]
        [< 00a198f4 >]
        [< 00a1956c >]
        [< 00a19a98 >]
        [< 00a191a4 >]
        [< 00a2f808 >]
        [< 00a3024c >]
        [< 00a198f4 >]
        [< 00a1956c >]
        [< 00a1956c >]
        [< 00a19a98 >]
        [< 00a191a4 >]
        [< 00a2f808 >]
        [< 00a3024c >]
        [< 00a198f4 >]
        [< 00a1956c >]
        [< 00a19a98 >]
        [< 00a191a4 >]
        [< 00a2f808 >]
        [< 00a3024c >]
        [< 00a198f4 >]
        [< 00a19a98 >]
        [< 00a191a4 >]
        [< 00a2f808 >]
        [< 00a3024c >]
        [< 00a198f4 >]
        [< 00a19a98 >]
        [< 00a191e8 >]
        [< 00a196b0 >]
        [< 00a1956c >]
        [< 00a19a98 >]
        [< 00a191a4 >]
        [< 00a2f808 >]
        [< 00a3024c >]
        [< 00a198f4 >]
        [< 00a19a98 >]
        [< 00a191a4 >]
        [< 00a2f770 >]
        [< 00a1a140 >]
        [< 00a17c20 >]
        [< 00a1a7bc >]
        [< 00aa1fa8 >]
        [< 00a1aa3c >]
        [< 00a01e00 >]

Copy info from "Call trace..." to a file(eg. dump.txt), and run
command in your U-Boot project: ./scripts/stacktrace.sh dump.txt

Resetting CPU ...
ERROR ### Please RESET the board

```

Could someone please point me in the right direction?

---

<div class="post-metadata">

**Author:** ![hipboi](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/hipboi/32/1682_2.png) [@hipboi](https://hub.mender.io/u/hipboi)\
**Post date:** [July 19, 2022, 11:31pm UTC](https://hub.mender.io/t/porting-for-rk3566-radxa-cm3/5133/2 "2022-07-19T23:31:47Z")

</div>

Where is your BSP u-boot and kernel come from? I suggest you integrate on the Debian provided by Radxa.

---

<div class="post-metadata">

**Author:** ![milp](https://avatars.discourse-cdn.com/v4/letter/m/82dd89/32.png) [@milp](https://hub.mender.io/u/milp)\
**Post date:** [July 20, 2022, 10:12am UTC](https://hub.mender.io/t/porting-for-rk3566-radxa-cm3/5133/3 "2022-07-20T10:12:34Z")

</div>

Sorry i should have elaborated that more clearly:

I used mender convert, based on the rockpro64 config, and replaced the U-boot with the one from

[GitHub - radxa/u-boot: U-Boot tree for pending commits](https://github.com/radxa/u-boot) using branch stable-4.19-rock3  
I then proceeded to manually integrate all the patches that didn’t automatically integrate into the uboot sources.  
building like this:

```auto
make radxa-cm3-io-rk3566_defconfig
make
make BL31=rkbin-tools/bin/rk35/rk3568_bl31_v1.32.elf u-boot-dtb.bin spl/u-boot-spl.bin u-boot.itb
make envtools

tools/mkimage -n rk3568 -T rksd -d rkbin-tools/bin/rk35/rk3566_ddr_1056MHz_v1.10.bin rksd_loader.img
cat spl/u-boot-spl.bin >> rksd_loader.img
dd if=u-boot.itb of=rksd_loader.img seek=448 conv=notrunc

```

The rest of the BSP comes from the stock Radxa Debian, where mender-convert added the mender client.
