Skip to content
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

Microbit v2 specific features #763

Merged
merged 57 commits into from
Aug 20, 2021

Conversation

gerargz
Copy link
Contributor

@gerargz gerargz commented Jan 6, 2021

Draft PR with microbit v2 specific features. This contains the commit ID for the DAPLink build used by the factory release of the microbit v2 boards.

This PR is still a draft as it contains modifications to the DAPLink core that may not be upstream friendly.

gerargz added 30 commits August 20, 2020 10:37
-Added ROM setting to enable/disable feature via .cfg files.
-Implemented hook at flash_decoder layer once the first 12 vectors are obtained (flash decoder min size)
-hook for custom reset button handling
-hook for 30ms event tick
-hook for power down event
-usb state udpate
-Add KL27Z NXP drivers
-Power monitor (detect power source)
-Board Rev Id detection
-i2c support
-low power support
-button and LED handling
-build filesystem hook for error blob app and DATA.BIN file creation
-Added microbit custom BL project for custom URL in HELP_FAQ.HTM
-I2C comms and flash interface
-SWD clock speed improvements
-Make power LED remain active in VLPS mode. Changed FlexIO source clock to one that is active in VLPS.
-Removed NRF Power mode property
-Added Power LED sleep state property
-Changed size of properties 0x01-03 to 2B
-Add property for Kl27 user event (wakeup or long button press)
-Blink LED when attempting to enter deep sleep but are PC connected
-Hold interrupt line to send I2C message on reset long press
-Clear I2C responses after first read in the comms interface
-Change wake up when the reset button is pressed instead of released
-Add hook in bootloader project to bypass reset button check to jump directly to the interface
-Reset the nRF whenever we wakeup from the reset button independently of the press duration
-Keep red LED ON after a long press.
-When the reset button is pressed, the KL27 will reset the `Power LED Sleep state` value to the default ON
-Red LED in deep sleep mode now depends on the `Power LED Sleep state` it can be either HIGH or LOW but no PWM.
…this command doesn't assert the interrupt line.
… of waiting to the main loop poll to update the status.
-Add support for reading flash config data
-Change filesize to bytes instead of KB
-Fix address ranges in erase storage cmd
-Add more validations to different commands
- Set backdoor key to 'MICROBIT'.
- Enable FPROT for first 32 kB of flash.
- Fix FPROTx numbering according to KL27 RM, where FPROT3 is at address 0x408.
- Enable backdoor key in FSEC.
- Added asterisks next to selected options in comments for FOPT and FSEC.
Copy link
Contributor

@microbit-carlos microbit-carlos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a couple of clarifications/notes and questions we had.

source/daplink/drag-n-drop/flash_decoder.c Show resolved Hide resolved
source/daplink/drag-n-drop/vfs_user.c Outdated Show resolved Hide resolved
source/board/microbitv2/microbitv2.c Show resolved Hide resolved
source/daplink/cmsis-dap/DAP_vendor.c Show resolved Hide resolved
source/daplink/cmsis-dap/DAP.c Show resolved Hide resolved
@flit
Copy link
Collaborator

flit commented Jan 6, 2021

Thanks for the PR! I probably won't be able to get to it until this weekend at the earliest.

# Conflicts:
#	records/tools/version.yaml

Resolved using DAPLink version 256 from master
(cherry picked from commit 1d7ad5d)

Modifications:
-Only define MICROBIT_LOCK_BOOTLOADER for kl27z_microbit_bl project
-Keep only one common: section in kl27z_microbit_bl.yaml
Copy link
Collaborator

@flit flit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My apologies for taking so long to review! There are a couple things on my list to come back to look at again. Overall, really good work! My comments are mostly nitpicks. 😉

records/board/microbitv2.yaml Outdated Show resolved Hide resolved
source/board/kl27z_microbit_bl.c Outdated Show resolved Hide resolved
source/board/microbitv2/i2c.h Outdated Show resolved Hide resolved
source/board/microbitv2/i2c.c Outdated Show resolved Hide resolved
source/board/microbitv2/led_error_app.h Outdated Show resolved Hide resolved
source/daplink/drag-n-drop/vfs_user.c Outdated Show resolved Hide resolved
source/daplink/interface/main.c Outdated Show resolved Hide resolved
source/daplink/interface/swd_host.c Outdated Show resolved Hide resolved
source/hic_hal/freescale/kl27z/DAP_config.h Outdated Show resolved Hide resolved
source/hic_hal/freescale/kl27z/usb_config.c Outdated Show resolved Hide resolved
update formatting
made microbit specific changes to be board configurable via yaml files

if (sector_offset != 0) {
if (sector_offset > 1) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably depend on the value of BOARD_EXTRA_BUFFER

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated calculation.

Consider BOARD_EXTRA_BUFFER in sector offset calculation
Follow ADIv6 for powering down the debug interface
Add comment to .yaml file on DELAY_FAST_CYCLES
Don't erase target image if incompatible image is enabled and triggered.
@gerargz gerargz force-pushed the microbit_features branch from 90b6221 to 44a2522 Compare August 19, 2021 19:03
@gerargz gerargz marked this pull request as ready for review August 19, 2021 19:11
@mathias-arm mathias-arm requested a review from flit August 20, 2021 14:26
Comment on lines +137 to +138
// TODO: put the interface chip in sleep mode
}
Copy link
Collaborator

@flit flit Aug 20, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just noticed that the while(1); from main() is missing here.

It's probably ok if the main loop keeps running, and might actually be better: RTX will block on the osThreadFlagsWait() call and enter the idle thread which will WFI.

But has this been tested on a build without the micro:bit override of this hook? (Is there even a way to enter powerdown for "normal" builds?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I remember correctly I initially had the while(1); in the weak function, but this had strange behavior where the code wasn't executing correctly in the "strong" custom function. I think it had to do with how the compiler optimizations were working. Something about the optimizations being done per file, without knowing that there was a "strong" function definition elsewhere. That and the combination of having an endless loop in the weak function, made the optimizations assume wrong things.

I don't see any build that uses the main_powerdown_event() to trigger this event, so the while(1) was probably a placeholder and there's no impact by removing it, I think.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, cool. Nothing to worry about then. Thanks for the quick answer!

Copy link
Collaborator

@flit flit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. Really fantastic work @gerargz!

The only outstanding question is the new one about the missing while(1); from the powerdown hook. Ideally I'd like to get an answer before this is actually merged, but it's not a big deal either way.

@flit
Copy link
Collaborator

flit commented Aug 20, 2021

All questions addressed, ready for merge! 🚀

@mathias-arm mathias-arm merged commit 9488528 into ARMmbed:main Aug 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants