Commit Graph

9398 Commits

Author SHA1 Message Date
Ayke van Laethem
987381dfa0 nrf: Make machine.UART optional.
Leave it enabled by default on all targets.

This is only possible when using UART-over-BLE (NUS) instead of the
default hardware peripheral. The flash area saved is quite substantial
(about 2.2KB) so this is useful for custom builds that do not need UART.
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
f679ee2092 nrf/drivers/ble_drv: Fixing sd_ble_enable bug for SD s132 v.2.0.1
Feather52 target which is using SD s132 v.2.0.1 cannot compile
due to variable containing RAM start address is not used.

This patch enables the correct sd_ble_enable variant for this SD.
2018-07-18 17:12:25 +10:00
Ayke van Laethem
f907139fab nrf/boards/common.ld: Avoid overflowing the .text region.
Similar commit to this one:
6e56e6269f

When .text + .data oveflow available flash, the linker may not show an
error. This change makes sure .data is included in the size calculation.
2018-07-18 17:12:25 +10:00
Ayke van Laethem
4c011e66b4 nrf/modules/machine/pin: Disable pin debug by default.
Saves for the nrf51:
flash: 336 bytes
RAM:     4 bytes
2018-07-18 17:12:25 +10:00
Ayke van Laethem
1b988f1e7d nrf/mpconfigport: Reduce GC stack size for nrf51.
This frees 128 bytes of .bss RAM on the nRF51, at the cost of possibly
more expensive GC cycles. Leave it as-is on the nRF52 as that chip has a
lot more RAM.

This is also done in the micro:bit:
a7544718a7/inc/microbit/mpconfigport.h (L6)
2018-07-18 17:12:25 +10:00
kaasasolut
c1cd7e5155 nrf: Only search for frozen files if FROZEN_MPY_DIR is set 2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
725267df09 nrf: Change PYB prefix to MPY 2018-07-18 17:12:25 +10:00
glennrub
f8f14bf0c7 nrf: Add support for s132 v5.0.0 bluetooth stack (#139)
* ports/nrf/boards: Adding linker script for nrf52832 using BLE stack s132 v.5.0.0.

* ports/nrf/drivers/bluetooth: Updating makefile to add BLE_API_VERSION=4 if s132 v5.0.0 is used.

* ports/nrf/drivers/bluetooth: Updating BLE stack download script to also download S132 v5.0.0.

* ports/nrf/drivers/bluetooth: Updating ble_drv.c to handle BLE_API_VERSION=4 (s132 v5.0.0).

* ports/nrf/boards: Updating linker script for nrf52832 with s132 v.5.0.0 bluetooth stack.

* ports/nrf/drivers/bluetooth: Removing commented out code in ble_drv.c

* ports/nrf/drivers/bluetooth: Updating define of GATT_MTU_SIZE_DEFAULT for SD132v5 to be defined using the new name defined in the SD headers in a more generic way.

* ports/nrf/drivers/bluetooth: Cleaning up use of BLE_API_VERSION in the ble_drv.c. Also considering s140v6 API, so not all has been changed to >= if API version 3 and 4 in combo is used. New s140v6 will differ on these, and add a new API not compatible with the API for 3 and 4.
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
95bd20522a nrf/drivers/bluetooth: Reset evt_len to size of static buffer each iter.
For each iteration of polling BLE events from the Bluetooth LE stack.
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
c8fd71612b nrf/boards/microbit: Enable music, display, image, microbit module.
Enabled by default on microbit targets, with or without BLE stack.  Also
enable softpwm to make display and music module compile.
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
f5ed40116f nrf: Add if-def around inclusion of nrf_sdm.h in main.
Not all targets are using bluetooth le.
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
6062d46170 nrf: Change board module header from board_modules.h to boardmodules.h.
Applicable for targets with board specific modules.
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
0d7976deb2 nrf/boards/microbit: Update docs on top level tick low pri callback. 2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
1128aacb69 nrf/boards/microbit: Add temperature back to microbit module.
Increases size by 68 bytes.  Should be considered to be removed as temp
module is already providing this functionality.
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
b6d01a7dd1 nrf/boards/microbit/modules: Fix tabbing in modmicrobit.c. 2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
5601fc9397 nrf/boards/microbit: Move microbit target to custom linker script.
To use if BLE stack is enabled.  The custom linker script also set off
space enough to compile in microbitfs+hal_nvmc.
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
67b57bebec nrf: Update main.c to init relevant board drivers, if enabled.
If the board has these drivers then they will be initialized:
- softpwm (implicit ticker)
- music module
- board specific module
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
f8ae6b7bfc nrf/modules/music: Remove init of softpwm/ticker upon music module load.
Also update microbit_music_init0 to register low priority ticker callback
for the music module.
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
789f8f1c4b nrf/boards/microbit: Update to work with new ticker code.
- Rename microbit_module_init to board_module_init0 which is the generic
  board module init function.
- Add low priority callback registration of display tick handler in the
  module init function.
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
91fcde73d2 nrf/drivers/ticker: Rework ticker functions for microbit display/music.
- Rename init function to ticker_init0.
- Implement ticker_register_low_pri_callback (recycle of unused
  set_low_priority_callback function which was unimplemented).
- Add support for registering 2 low pri callbacks.  For now, one intended
  for microbit display, and one for modmusic.
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
7c74b7da48 nrf/drivers/softpwm: Rename init function to softpwm_init0. 2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
d76982e382 nrf/boards/microbit: Include modmicrobit.h in board_modules.h.
So that users of the board module can find the init function of the module
implicitly.
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
0b504575e2 nrf/boards/microbit: Add modmicrobit.h to expose module init function. 2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
1b241be310 nrf/boards/microbit: Attempt to get working display/images without FP.
And update the API to align with new unary/binary function callback
structures.
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
9e090a8783 nrf/boards/microbit: Add framework updates to build micro:bit modules.
Makefile and mpconfigport.h update is generic, and could be used by other
boards to give extra modules which are only for a selected board.
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
fbc45bd3f3 nrf/boards/microbit: Update board modules from C++ to C-code.
This aligns implementation with new style structures.
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
f3386cfc50 nrf/boards/microbit: Rename display/image files from .cpp to .c ext.
Also rename modmicrobit.h to microbitconstimage.h.
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
98ad4107ef nrf/boards/microbit: Add copy of microbit font type from microbit-dal.
Source: https://github.com/lancaster-university/microbit-dal.git
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
7a2e136049 nrf/boards/microbit: Add copy of microbit display and image files.
From micro:bit port repository, https://github.com/bbcmicrobit/micropython
2018-07-18 17:12:25 +10:00
Ayke van Laethem
a248db6916 nrf: Option to enable Ctrl-C in NUS console.
Costs 136 bytes on a nRF51822.
2018-07-18 17:12:25 +10:00
Ayke van Laethem
03b8429c0c nrf: Remove default FROZEN_MPY_DIR.
Saves 448 bytes of flash. Can still be enabled using:

    make FROZEN_MPY_DIR=freeze BOARD=foo
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
b493de75f3 nrf: Update usage of mp_obj_new_str by removing last parameter. 2018-07-18 17:12:25 +10:00
Ayke van Laethem
fc5d89e29d nrf/drivers/bluetooth: Start advertising after disconnect.
Disconnecting after a connect would not restart advertising, so
reconnecting may get harder.
2018-07-18 17:12:25 +10:00
Ayke van Laethem
2561bcf0c0 nrf/main: Add ampy support.
The ampy tool expects a "soft reboot" line when it does a soft reset.
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
2b32333f90 nrf: Use micropython libm to save flash
Using libm from micropython free up about 5.5kb flash on nrf52
targets which have floating point enabled.
2018-07-18 17:12:25 +10:00
Ayke van Laethem
d9fb8c2585 nrf/main: Run boot.py and main.py on startup. 2018-07-18 17:12:25 +10:00
Ayke van Laethem
66e39d6a4e nrf/modules/uos/microbitfs: Make OSError numeric.
This saves about 80 bytes of code size.
2018-07-18 17:12:25 +10:00
Ayke van Laethem
8482daced2 nrf/drivers/bluetooth/ble_drv: Don't handle non-events.
When there is a non-BLE event (sd_evt_get), the ble_evt_handler is
invoked anyway even if it returns NRF_ERROR_NOT_FOUND.
2018-07-18 17:12:25 +10:00
Ayke
f7facf73f1 nrf: Add micro:bit filesystem.
* ports/nrf: Add micro:bit filesystem.

This filesystem has been copied from BBC micro:bit sources [1] and
modified to work with the nRF5x port.

[1]: https://github.com/bbcmicrobit/micropython/blob/master/source/microbit/filesystem.c

* ports/nrf/modules/uos: Make listdir() and ilistdir() consistent.

This removes the optional direcotry paramter from ilistdir(). This is
not consistent with VFS, but makes more sense when using only the
microbit filesystem.

Saves about 100 bytes.

* ports/nrf/modules/uos: Add code size comment.
2018-07-18 17:12:25 +10:00
Ayke van Laethem
fcc1568546 nrf/boards: Update linker scripts.
* Remove FLASH_ISR and merge .isr_vector into FLASH_TEXT. This saves
    some code space, especially on nRF52 devices.
  * Reserve space for nonvolatile storage of data. This is the place for
    a filesystem (to be added).
2018-07-18 17:12:25 +10:00
Ayke van Laethem
83f38a99a9 nrf/hal/hal_nvmc: Fix non-SD code.
The code wasn't tested yet without a SoftDevice.
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
a2b4c93e85 nrf/hal/nvmc: Remove pre-compiler error thrown in nvmc.h, if on nrf52.
This has been tested and works.
2018-07-18 17:12:25 +10:00
Ayke van Laethem
7418795fdf nrf: Disable FAT/VFS by default.
Most boards don't have an SD card so it makes no sense to have it
enabled. It can be enabled per board (mpconfigboard.h).
2018-07-18 17:12:25 +10:00
Ayke van Laethem
cc158f98fe nrf: Implement NVMC HAL.
This is only a library for flash access. Actual file system support will
be added later.
2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
0487e23842 nrf/boards/arduino_primo: Add missing hal_rng config used by random mod. 2018-07-18 17:12:25 +10:00
Ayke van Laethem
4838b398af nrf: Enable Link-time optimizations 2018-07-18 17:12:25 +10:00
Ayke van Laethem
4e083819f3 nrf: Add compile switch to disable VFS.
This saves about 17kB.
2018-07-18 17:12:25 +10:00
Ayke van Laethem
38afc6553c nrf: Use --gc-sections to reduce code size
This saves about 6-7kB.
2018-07-18 17:12:25 +10:00
Ayke van Laethem
a1116771b0 nrf: Add WT51822-S4AT board. 2018-07-18 17:12:25 +10:00
Glenn Ruben Bakke
51a679752a nrf: Update Makefile and README.md after moving port to new directory 2018-07-18 17:12:25 +10:00