-
-
Notifications
You must be signed in to change notification settings - Fork 779
Initial support for the Artemis platform #1857
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Ok, so I figured out that with this diff the hard fault is fixed: diff --git a/arch/cortex-m4/src/lib.rs b/arch/cortex-m4/src/lib.rs
index 00fe99d84..2827d602a 100644
--- a/arch/cortex-m4/src/lib.rs
+++ b/arch/cortex-m4/src/lib.rs
@@ -89,10 +89,6 @@ pub unsafe extern "C" fn generic_isr() {
mov r0, #0
msr CONTROL, r0
- // This is a special address to return Thread mode with Main stack
- movw LR, #0xFFF9
- movt LR, #0xFFFF
-
// Now need to disable the interrupt that fired in the NVIC to ensure it
// does not trigger again before the scheduler has a chance to handle it. We
// do this here in assembly for performance.Any ideas what is going on here? |
|
Those two lines of assembly write a particular EXC_RETURN value to the cortex-m4 link register. Accordingly, This may be a clue (from ARMs notes on what registers are different for the m4f): http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dai0298a/BCGHEEFD.html : "The EXC_RETURN code value which is used in the exception mechanism has an additional bit field to define floating-point stack status. When the value of EXC_RETURN[4] is 0, it indicates that the exception stack frame for an exception return contains floating-point registers. If this bit is 1, then it means the exception stack frame does not contain floating-point registers." So perhaps this value should be different because you are using an m4f? In particular, perhaps the first line should be Disclaimer: I am not an expert on Tock's interrupt handling or on Cortex-m interrupt handling in general so maybe (probably?) this is totally wrong, but figured I'd post it on the off chance it is helpful |
|
That changes the error from (with the two lines included): To (with So an improvement? |
5f92dca to
626d4b6
Compare
|
Wait, 0-indexing - try 0xFFE9? |
|
That's it! Awesome I have updated the PR description to remove the hard fault printout. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This. Is. Awesome.
I'm really excited to see an Ambiq chip in Tock.
We can probably get away without it for a little while, but we definitely should add a cortex-m4f arch to Tock. If we ever start using the floating point acceleration, we will need a different UKB implementation. Leaving the floating point hardware turned off so it can masquerade as a regular m4 is a good way to start though.
In Interrupt mode, with an One subtlety here is that when FPU is used, the exception stack frames are different. There is a reasonable chance that our user-space programs would break. |
Looking through the apollo3 code in this PR I don't see anything that looks like it should be enabling the FPU, and per https://developer.arm.com/docs/dui0553/b/cortex-m4-peripherals/floating-point-unit-fpu/enabling-the-fpu it is disabled by default. So I wonder why |
I have a strange suspicion that the MCU vendor might be enabling FPU in their mask ROM, before handing control over to us. @alistair23 - I was wondering what is the value of the |
|
Which one is the control register? |
626d4b6 to
a18888c
Compare
|
I have pushed an update that works with the LED now. I also have tidied up the GPIO driver (although some bits are unimplemented). I have also fixed the UART to run the callback so that multiple prints work. Let me know what you think. |
5c82a85 to
061d35b
Compare
|
The CONTROL register isn't printed by default unfortunately. You can use the move special register ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are a few comments.
I do think it would be nice to figure out if the FPU can be disabled so that the interrupt handler for this chip can be the same as what we use for other m4f boards for now.
Also, the GPIO driver uses a decent amount of "magic numbers" (padkey value, etc.), but I don't think this needs to block on fixing those.
|
So after running r0 is: |
|
Oops, sorry, that was a lazy pointer on my part. I believe that will write r0 into control; you need to MRS ( http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.dui0489c/Cihjcedb.html ):
In general, in ARM assembly, the leftmost operand is the destination |
|
Ha, I should have thought about it and known that. Anyway, |
As I suspected, |
061d35b to
08cffcb
Compare
|
Ok. Thanks to @rajivr I can now disable the FPU and don't need anything special in the interrupt handling. It strangely needs a Otherwise I have addressed all the comments. I'm going to mark this as ready for review. |
08cffcb to
c69adbc
Compare
|
I have the hello_world and LED blink examples work (although the timer doesn't) from |
c69adbc to
4d8cfba
Compare
|
|
723b2c1 to
f8a1439
Compare
1870: move duplicated unhandled_interrupt code to cortex-m4 crate r=ppannuto a=hudson-ayers ### Pull Request Overview While reviewing #1857, I noticed that apollo3 would be the fifth chip crate to introduce an identical `fn unhandled_interrupt()` definition. The assembly for checking the currently active interrupt is cortex-m4 specific, but not chip specific (https://developer.arm.com/docs/dui0553/a/the-cortex-m4-processor/programmers-model/core-registers), so I thought it would be good to cut down on duplicated code by moving this definition to the cortex-m4 crate. Nothing stops chips from defining their own `unhandled_interrupt` if a different implementation is desired. The cc26x2 chip previously used an `unhandled_interrupt()` that just looped forever, but I changed it to use this shared implementation as a panic seems strictly more useful than a hang. ### Testing Strategy This pull request was tested by `make allboards`. ### TODO or Help Wanted N/A ### Documentation Updated - [x] No updates are required. ### Formatting - [x] Ran `make format`. - [x] Fixed errors surfaced by `make clippy`. Co-authored-by: Hudson Ayers <[email protected]>
f8a1439 to
426907c
Compare
Signed-off-by: Alistair Francis <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
Signed-off-by: Alistair Francis <[email protected]>
426907c to
3e4c384
Compare
|
I pushed an update with the doc fixes requested by @bradjc. This should be good to go :) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bors r+
🎉
Pull Request Overview
SparkFun have create the Artemis MCU module. It's a Ambiq Apoll3 MCU broken out so that it's ready to be used. On top of this they have a range of boards that you can use.
This PR is the first go at supporting the Apollo3 MCU and the RedBoard Artemis Nano.
Datasheet for the MCU: https://ambiqmicro.com/static/mcu/files/Apollo3_Blue_MCU_Data_Sheet_v0_11_0.pdf
What works:
libtock-rsappsTesting Strategy
Running on the SparkFun RedBoard Artemis Nano.
TODO or Help Wanted
The main missing features right now are:
Not all of them need to be done before this can be merged.
Documentation Updated
/docs, or no updates are required.Formatting
make formatall.