Hard Fault in _port_switch on LPC1347

ChibiOS public support forum for topics related to the NXP LPC family of Cortex-M micro-controllers.

Moderator: theShed

Dzarda
Posts: 2
Joined: Sat Feb 28, 2015 2:28 pm
Location: Brno, Czech Republic

Hard Fault in _port_switch on LPC1347

Postby Dzarda » Sun Jun 12, 2016 2:57 pm

I realize this is an unsupported platform.
Hello :)

Background Info:

I'm currently playing with ChibiOS/RT 3.1.2 on the LPCXpresso 1347 board.

I added support for the LPC1347 MCU according to the project standards. The relevant files added to the OS can be found here
chibios_lpc1347.zip
lpc1347.h, LPC1347.ld, cmparams.h
(4.63 KiB) Downloaded 35 times


Problem:

Upon executing the last instruction in the assembly routine _port_switch, the core ends up in a HardFault_Handler as the SP gets loaded with zeros.

Code: Select all

          _port_switch:
00000190:   stmdb   sp!, {r4, r5, r6, r7, r8, r9, r10, r11, lr}
00000194:   str.w   sp, [r1, #12]
00000198:   ldr     r3, [r0, #12] ;<<< *(R0+12) contains 0x00000000
0000019a:   mov     sp, r3 ;<<< SP is set to 0, beginning of the end
0000019c:   ldmia.w sp!, {r4, r5, r6, r7, r8, r9, r10, r11, pc} ;<<< Hard Fault


Here's the stack trace that leads to this _port_switch call:
(There are _port_switch calls before this one that don't fail - e.g. from chThdCreateStatic)

Code: Select all

   _port_switch() at 0x19a   
   chSchGoSleepS() at chschd.c:269 0xa90   
   chSchGoSleepTimeoutS() at chschd.c:338 0xb52   
   chThdSleepS() at chthreads.h:268 0xdfa   
   chThdSleep() at chthreads.c:314 0xfb0   
   Thread1() at main.c:9 0x13a4   
   _port_thread_start() at 0x1b2   


Here's main:
► Show Spoiler


Here's the Makefile:
► Show Spoiler


I'd be happy for any pointers to what am I doing wrong.

User avatar
Giovanni
Site Admin
Posts: 10321
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 227 times
Been thanked: 205 times
Contact:

Re: Hard Fault in _port_switch on LPC1347

Postby Giovanni » Sun Jun 12, 2016 5:32 pm

Hi,

Check for common errors, stack overflows for example, LPC devices should work without problems.

Giovanni

Dzarda
Posts: 2
Joined: Sat Feb 28, 2015 2:28 pm
Location: Brno, Czech Republic

Re: Hard Fault in _port_switch on LPC1347

Postby Dzarda » Tue Nov 01, 2016 10:13 pm

I tried to add support for the LPC device to the current trunk's RT and the problem seems to have disappeared.

User avatar
Giovanni
Site Admin
Posts: 10321
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 227 times
Been thanked: 205 times
Contact:

Re: Hard Fault in _port_switch on LPC1347

Postby Giovanni » Tue Nov 01, 2016 10:21 pm

Hi,

Good to know :)

Giovanni

astoneb
Posts: 3
Joined: Tue Jan 10, 2017 11:40 pm

Re: Hard Fault in _port_switch on LPC1347

Postby astoneb » Tue Jan 10, 2017 11:51 pm

Hello everybody,

i have currently exactly the same problem with the stm32f4discovery.
Are there may be a few details on the problem and how to solve it?

I am new to chibios and not quite so experienced with the system ...

User avatar
Giovanni
Site Admin
Posts: 10321
Joined: Wed May 27, 2009 8:48 am
Location: Salerno, Italy
Has thanked: 227 times
Been thanked: 205 times
Contact:

Re: Hard Fault in _port_switch on LPC1347

Postby Giovanni » Wed Jan 11, 2017 8:46 am

Hi,

Please post questions related to STM32 in the STM32 forum. All the F4 demos work as intended and you don't give any detail about your setup, please have a look to this article:

http://chibios.org/dokuwiki/doku.php?id ... ebug_guide

Giovanni


Return to “LPC Support”

Who is online

Users browsing this forum: No registered users and 1 guest