[Tiva TM4C123] [solved] I'm getting a hard fault when initializing a Pin

Discussion and questions about boards that can run MicroPython but don't have a dedicated forum.
Target audience: Everyone interested in running MicroPython on other hardware.
Post Reply
ExXec
Posts: 33
Joined: Sat Oct 20, 2018 4:02 pm

[Tiva TM4C123] [solved] I'm getting a hard fault when initializing a Pin

Post by ExXec » Sat Dec 15, 2018 8:17 pm

Hey everybody,

I'm currently in the process of porting uPy to the Tiva Launch Pad.

I'm having problems calling
>>> p = Pin('PF2', Pin.OUT)
because the controller goes into the FaultISR(). (Handler for hard faults)
I suspect a nullpointer dereference, but not in my own code, so I have no idea why.
'PF2' is a valid pin name.

The callstack looks like this:
uPy1.PNG
Callstack
uPy1.PNG (18.28 KiB) Viewed 318 times
And in this line the fault happens:
uPy2.PNG
Line of fault
uPy2.PNG (44.19 KiB) Viewed 318 times
I cannot step into it.
Here are the values of the local variables right before the call:
uPy3.PNG
Local Variables
uPy3.PNG (7.5 KiB) Viewed 318 times
Does anybody know why this is happening?

I'm grateful for any ideas!
-ExXec
-------------------------------------------------------------------------
My fork: https://github.com/ExXeptional/micropyt ... ts/tm4c123
Last edited by ExXec on Sun Dec 16, 2018 10:02 pm, edited 1 time in total.

User avatar
dhylands
Posts: 3067
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: [Tiva TM4C123] I'm getting a hard fault when initializing a Pin

Post by dhylands » Sun Dec 16, 2018 12:18 am

You show that fun_in is 0x00000000 so the address of the routine you're trying to call is the null pointer, which is what's causing the exception and why you can't step into it.

So you need to work backwards and figure out why fun_in is null.

ExXec
Posts: 33
Joined: Sat Oct 20, 2018 4:02 pm

Re: [Tiva TM4C123] I'm getting a hard fault when initializing a Pin

Post by ExXec » Sun Dec 16, 2018 1:43 am

Ok, I tracked it down to this expression:

Code: Select all

MP_STATE_PORT(pin_class_mapper)
this returns 0x00000000


I copied that part from the stm32 port, so I don't know what this does

User avatar
dhylands
Posts: 3067
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: [Tiva TM4C123] I'm getting a hard fault when initializing a Pin

Post by dhylands » Sun Dec 16, 2018 6:11 am

The code only calls that function if pin_class_mapper is not equal to mp_const_none. mp_const_none isn't the value 0x00000000
pin_class_mapper is initialized to mp_const_none in the function pin_init0 which should be called from your main.c as it is here:
https://github.com/micropython/micropyt ... ain.c#L587

ExXec
Posts: 33
Joined: Sat Oct 20, 2018 4:02 pm

Re: [Tiva TM4C123] I'm getting a hard fault when initializing a Pin

Post by ExXec » Sun Dec 16, 2018 6:15 pm

yeah that was the problem, thanks :D

Post Reply