Porting the Firmware to a new ASIC

Hi all .
I am trying to porting the PX4 to a new ASIC, with 2 cores cortex-m7.
Now I meet some problem.

The spi has 3 port :
the memory FM25V01-G is on the port 1.
the ms5611 is on the port 4.
the icm 20602 & icm 20689 & bmi055 are on the port 6.
I write the new spi drivers ar_spi.c to instead the stm32_spi.c
Now, the mtd (FMV25V01-G ) is init success. the ms5611 can also bring up success.
but when I input the “mpu6000 -R 8 -s -T 20602 start” on the console.
The system will happen a hardfault error and the system restart. only a few time the imu can bring up success.

the R14 and the R15 show that the mm_free() cause the hardfualt .

who can help me ? I want to know how to debug the error ?

NuttShell (NSH)
nsh> mpu6000 -R 8 -s -T 20602 start
spi_setfrequency: Frequency 1000000->1000000
spi_setfrequency: divider = 128
MPU6000 on SPI bus 6 at 1 (1000 KHz)
INFO [mpu6000] accel cutoff set to 30.00 Hz
INFO [mpu6000] gyro cutoff set to 80.00 Hz
INFO [mpu6000] 1-----------------------------
INFO [mpu6000] 2-----------------------------
INFO [mpu6000] 3----------------------------up_hardfault: PANIC!!! Hard fault: 40000000
up_assert: Assertion failed at file:armv7-m/up_hardfault.c line: 171 task: init
up_dumpstate: sp: 20000ec4
up_dumpstate: IRQ stack:
up_dumpstate: base: 20000ef0
up_dumpstate: size: 000002ec
up_dumpstate: used: 00000124
up_stackdump: 20000ec0: 10029937 00000003 1010ded4 1002993f 1002991d 100284b9 00000010 20010364
up_stackdump: 20000ee0: 20001010 00000003 0000507a 100282df 20010364 00000000 00000000 00000000
up_dumpstate: sp: 20010438
up_dumpstate: User stack:
up_dumpstate: base: 200090e8
up_dumpstate: size: 00000fec
up_dumpstate: used: 00000608
up_registerdump: R0: 00000003 2000ffb8 4001ffff 20010047 2000ffc0 20001010 00000003 0000507a
up_registerdump: R8: 00000008 00000010 00000007 1010ded4 00000000 20010438 1002adf5 1003cd68
up_registerdump: xPSR: 01000000 BASEPRI: 00000010 CONTROL: 00000000
up_registerdump: EXC_RETURN: ffffffe9
up_taskdump: Idle Task: PID=0 Stack Used=0 of 0
up_taskdump: hpwork: PID=1 Stack Used=632 of 2028
up_taskdump: lpwork: PID=2 Stack Used=416 of 2028
up_taskdump: init: PID=3 Stack Used=1544 of 4076

1002adec mm_takesemaphore :

1002adec: b538 push {r3, r4, r5, lr}
1002adee: 4604 mov r4, r0
1002adf0: f001 f8fa bl 1002bfe8
1002adf4: 4605 mov r5, r0
1002adf6: f9b4 3014 ldrsh.w r3, [r4, #20]
1002adfa: 4283 cmp r3, r0
1002adfc: d10c bne.n 1002ae18 <mm_takesemaphore+0x2c>
1002adfe: 69a3 ldr r3, [r4, #24]
1002ae00: 3301 adds r3, #1
1002ae02: 61a3 str r3, [r4, #24]
1002ae04: bd38 pop {r3, r4, r5, pc}
1002ae06: f000 f84f bl 1002aea8 <get_errno_ptr>
1002ae0a: 6803 ldr r3, [r0, #0]
1002ae0c: 2b04 cmp r3, #4
1002ae0e: d003 beq.n 1002ae18 <mm_takesemaphore+0x2c>

1003cd44 mm_free:

1003cd44: b570 push {r4, r5, r6, lr}
1003cd46: 4605 mov r5, r0
1003cd48: 460c mov r4, r1
1003cd4a: 2900 cmp r1, #0
1003cd4c: d044 beq.n 1003cdd8 <mm_free+0x94>
1003cd4e: f7ee f84d bl 1002adec <mm_takesemaphore>
1003cd52: f854 3c04 ldr.w r3, [r4, #-4]
1003cd56: f1a4 0108 sub.w r1, r4, #8
1003cd5a: f023 4300 bic.w r3, r3, #2147483648 ; 0x80000000
1003cd5e: f844 3c04 str.w r3, [r4, #-4]
1003cd62: f854 3c08 ldr.w r3, [r4, #-8]
1003cd66: 18ca adds r2, r1, r3
1003cd68: 6850 ldr r0, [r2, #4]
1003cd6a: 2800 cmp r0, #0
1003cd6c: db14 blt.n 1003cd98 <mm_free+0x54>
1003cd6e: 58cb ldr r3, [r1, r3]

Have you seen this?

thanks, I reset the stack of the MPU6500 for 1200 to 2400, the fault is disappeared.

1 Like