Skip to content

Commit 4f333a2

Browse files
Update to Mbed OS 6.14.0 & update config and examples.
All changes required due to the Mbed OS v6 changes.
1 parent 6adcd80 commit 4f333a2

File tree

13 files changed

+84
-2440
lines changed

13 files changed

+84
-2440
lines changed

.mbedignore

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1 @@
11
examples/*
2-
3-
# Uncomment the following entries to compile without RTOS
4-
# mbed-os/rtos/*
5-
# mbed-os/usb/*
6-
# mbed-os/features/cellular/*
7-
# mbed-os/features/cryptocell/*
8-
# mbed-os/features/FEATURE_BLE/*
9-
# mbed-os/features/FEATURE_CLIENT/*
10-
# mbed-os/features/FEATURE_COMMON_PAL/*
11-
# mbed-os/features/FEATURE_UVISOR/*
12-
# mbed-os/features/frameworks/*
13-
# mbed-os/features/net/*
14-
# mbed-os/features/netsocket/*
15-
# mbed-os/features/nanostack/*
16-
# mbed-os/features/nvstore/*
17-
# mbed-os/features/storage/*
18-
# mbed-os/features/device_key/*
19-
# mbed-os/features/lorawan/*
20-
# mbed-os/features/lwipstack/*
21-
# mbed-os/features/mbedtls/*
22-
# mbed-os/features/nanostack/*
23-
# mbed-os/features/netsocket/*
24-
# mbed-os/features/nfc/*
25-
# mbed-os/features/storage/*
26-
# mbed-os/features/unsupported/*
27-
# mbed-os/events/*
28-
# mbed-os/components/802.15.4_RF/*
29-
# mbed-os/components/storage/*
30-
# mbed-os/components/wifi/*

Makefile

Lines changed: 0 additions & 1934 deletions
This file was deleted.

README.md

Lines changed: 32 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,11 @@ This is a basic Mbed OS project for [micro:bit V2](https://microbit.org/new-micr
2121

2222
- git
2323
- [Arm GCC](https://developer.arm.com/tools-and-software/open-source-software/developer-tools/gnu-toolchain/gnu-rm/downloads)
24-
25-
**Mbed only requirements:**
24+
- v9.3.1 is the last tested version
2625
- Python 3
2726
- pip (version >= 10.0)
28-
- Mercurial
2927
- [Mbed CLI](https://github.com/ARMmbed/mbed-cli)
30-
- Last tested version is 1.10.2
31-
32-
**Make only requirements:**
33-
- srec_cat
34-
- Make
28+
- v1.10.2 is last tested version
3529

3630

3731
## Using Mbed
@@ -41,7 +35,7 @@ This is a basic Mbed OS project for [micro:bit V2](https://microbit.org/new-micr
4135
Install mbed-cli using one of the methods from the official documentation:
4236
https://os.mbed.com/docs/mbed-os/v5.12/tools/developing-mbed-cli.html
4337

44-
The manual installation (in a Python 2 virtual environment) is the prefer method.
38+
The manual installation (in a Python 3 virtual environment) is the prefer method.
4539

4640
### Multiple targets
4741

@@ -65,25 +59,6 @@ targets.
6559
The version of the board can be seen on the silkscreen at the back, near the
6660
right side of the edge connector.
6761

68-
### Mbed OS Version
69-
70-
We are currently locked to
71-
[v5.12.4](https://github.com/ARMmbed/mbed-os/releases/tag/mbed-os-5.12.4) as
72-
this is the last version to support Soft Device, which has been dropped in
73-
[v5.13+](https://github.com/ARMmbed/mbed-os/releases/tag/mbed-os-5.13.0):
74-
75-
> Default to Cordio BLE stack for NRF52* targets
76-
> [10709](https://github.com/ARMmbed/mbed-os/pull/10709)
77-
>
78-
> Starting with mbed-os 5.13 and the introduction of Nordic SDK V15, Nordic
79-
> SoftDevice Bluetooth stack is not supported. Bluetooth remains supported with
80-
> the help of Arm's Cordio stack.
81-
82-
### Mbed OS RTOS
83-
84-
To compile the project without the Mbed OS RTOS edit the `.mbedignore` and
85-
uncomment all the entries.
86-
8762
### Initialise
8863

8964
Note that for the `mbed target ...` line you should select the right target
@@ -130,73 +105,45 @@ mbed compile -m nrf52_microbit_v2 -t GCC_ARM
130105

131106
Build output can be found in: `./BUILD/NRF52_MICROBIT_V2/GCC_ARM/mbedos-microbit-v2-starter.hex`
132107

133-
If `mbed` cannot find the tools directory in mbed-os, then you may have to delete the mbed cache by removing `~/.mbed/`.
134-
135-
136-
## Using Make (back up option only)
108+
If `mbed` cannot find the tools directory in mbed-os, then you may have to
109+
delete the mbed cache by removing `~/.mbed/`.
137110

138-
The use of the Makefile is discouraged, and it is here only as a back up
139-
mechanism to compile the Mbed project.
140-
As the MakeFile is created based on the mbed project and some manual patches
141-
have to be applied, it is likely this method will fall behind compared the mbed
142-
method.
143-
144-
### Single target
145-
146-
Only the latest target is supported in the Makefile.
147-
148-
At the time of writing this would be v1.43.4 boards. Since the v1.44, v1.45,
149-
v1.46, v1.47 board updates does not affect the target configuration there was
150-
no need to regenerate the Makefile.
151-
152-
### Initialise
153-
154-
```
155-
git clone https://github.com/microbit-foundation/mbedos-microbit-v2-starter.git
156-
cd mbedos-microbit-v2-starter
157-
git clone https://github.com/ARMmbed/mbed-os.git
158-
```
159-
160-
Then open the `mbed-os.lib` file with a text editor, it should have something
161-
like this:
162-
163-
```
164-
https://github.com/ARMmbed/mbed-os/#73f096399b4cda1f780b140c87afad9446047432
165-
```
166-
167-
The sequence after the `#` is the git commit needed of mbed-os, so:
168-
169-
```
170-
cd mbed-os
171-
git reset --hard <commit_hash_here>
172-
```
173-
174-
### Build
175-
176-
From the `mbedos-microbit-v2-starter` folder run:
177-
178-
```
179-
make
180-
```
111+
### Mbed OS Version
181112

182-
Build output can be found in: `./BUILD/mbedos-microbit-v2-starter-combined.hex`
113+
This repo is currently configured Mbed OS to version
114+
[6.13.0]((https://github.com/ARMmbed/mbed-os/releases/tag/mbed-os-6.14.0)).
183115

184-
### Regenerate Makefile
116+
The branch `xxxx` (commit `6adcd80982dbf5c2a2ef876d21d0f4a08db91644`) is
117+
configured to [v5.12.4](https://github.com/ARMmbed/mbed-os/releases/tag/mbed-os-5.12.4),
118+
as this is the last Mbed OS version to support Soft Device.
185119

186-
The Makefile can be regenerated using mbed-cli, however keep in mind that there
187-
has been changes applied (the file header contains more information), and
188-
some of those changes (and the header info) might need to be preserved in the
189-
new regenerated version.
120+
### Mbed OS RTOS
190121

191-
```
192-
mbed-cli export -i GCC_ARM -m nrf52_microbit_v2 --profile develop
122+
This section needs to be updated to work with the Mbed OS v6 bare metal
123+
profile.
124+
125+
mbed_app.json:
126+
```
127+
{
128+
"requires": [
129+
"bare-metal",
130+
"drivers-usb",
131+
"events"
132+
],
133+
"target_overrides": {
134+
"*": {
135+
"target.c_lib": "small"
136+
}
137+
}
138+
}
193139
```
194140

195141

196142
## Visual Studio Code
197143

198144
At the moment we have the default config files from the Mbed online compiler
199-
project exporter. These are using `make` but could be updated to use `mbed-cli`.
145+
project exporter. These are using removed `make` and have to be updated to use
146+
`mbed-cli`.
200147

201148

202149
## Using NFC
@@ -207,18 +154,10 @@ as they are exposed via the Edge Connector to be used as normal GPIOs.
207154
To change this and use them for NFC you can perform the following changes:
208155
- Mbed: Update the `mbed_app.json` file to include a remove macro entry in the micro:bit target.
209156
```
210-
"NRF52_MICROBIT_v1_44": {
157+
"NRF52_MICROBIT_v2": {
211158
"target.macros_remove": ["CONFIG_NFCT_PINS_AS_GPIOS"]
212159
}
213160
```
214-
- Makefile: Remove the following lines from the makefile.
215-
```
216-
C_FLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS
217-
...
218-
CXX_FLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS
219-
...
220-
ASM_FLAGS += -DCONFIG_NFCT_PINS_AS_GPIOS
221-
```
222161
223162
224163
## License

TARGET_NRF52833_DK/PinNames.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ typedef enum {
174174
RTS_PIN_NUMBER = p5,
175175

176176
// mBed interface Pins
177-
USBTX = TX_PIN_NUMBER,
178-
USBRX = RX_PIN_NUMBER,
177+
CONSOLE_TX = TX_PIN_NUMBER,
178+
CONSOLE_RX = RX_PIN_NUMBER,
179179
STDIO_UART_TX = TX_PIN_NUMBER,
180180
STDIO_UART_RX = RX_PIN_NUMBER,
181181
STDIO_UART_CTS = CTS_PIN_NUMBER,

TARGET_NRF52_MICROBIT_v1_41/PinNames.h

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -122,11 +122,6 @@ typedef enum {
122122
P0_30 = p30,
123123
P0_31 = p31,
124124

125-
LED1 = p17,
126-
LED2 = p18,
127-
LED3 = p19,
128-
LED4 = p20,
129-
130125
// Buttons A and B
131126
BUTTON1 = P0_14,
132127
BUTTON2 = P0_15,
@@ -172,8 +167,8 @@ typedef enum {
172167
COMBINED_SENSOR_INT = P0_25,
173168

174169
// mBed interface Pins
175-
USBTX = TX_PIN_NUMBER,
176-
USBRX = RX_PIN_NUMBER,
170+
CONSOLE_TX = TX_PIN_NUMBER,
171+
CONSOLE_RX = RX_PIN_NUMBER,
177172
STDIO_UART_TX = TX_PIN_NUMBER,
178173
STDIO_UART_RX = RX_PIN_NUMBER,
179174
STDIO_UART_CTS = CTS_PIN_NUMBER,

TARGET_NRF52_MICROBIT_v1_43/PinNames.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,9 +156,6 @@ typedef enum {
156156
P1_14 = p46,
157157
P1_15 = p47,
158158

159-
// LED in the nRF52833 DK board
160-
LED1 = P0_13,
161-
162159
// Buttons A and B
163160
BUTTON1 = P0_14,
164161
BUTTON2 = P0_23,
@@ -203,8 +200,8 @@ typedef enum {
203200
RTS_PIN_NUMBER = p5,
204201

205202
// mBed interface Pins
206-
USBTX = TX_PIN_NUMBER,
207-
USBRX = RX_PIN_NUMBER,
203+
CONSOLE_TX = TX_PIN_NUMBER,
204+
CONSOLE_RX = RX_PIN_NUMBER,
208205
STDIO_UART_TX = TX_PIN_NUMBER,
209206
STDIO_UART_RX = RX_PIN_NUMBER,
210207
STDIO_UART_CTS = CTS_PIN_NUMBER,

custom_targets.json

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,16 +95,5 @@
9595
},
9696
"NRF52_MICROBIT_v2": {
9797
"inherits": ["NRF52_MICROBIT_v1_43"]
98-
},
99-
"NRF52_MICROBIT_v2_NOSD": {
100-
"inherits": ["NRF52_MICROBIT_v1_43"],
101-
"extra_labels_remove": [
102-
"NORDIC_SOFTDEVICE",
103-
"SOFTDEVICE_COMMON",
104-
"SOFTDEVICE_S140_FULL"
105-
],
106-
"extra_labels_add": [
107-
"SOFTDEVICE_NONE"
108-
]
10998
}
11099
}

examples/sensors.cpp

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,17 @@
4343
#endif
4444

4545

46+
BufferedSerial pc(CONSOLE_TX, CONSOLE_RX, 115200);
47+
48+
FileHandle *mbed::mbed_override_console(int fd) {
49+
return &pc;
50+
}
51+
4652
int main(void) {
4753
// Initialise the serial
48-
Serial pc(USBTX, USBRX);
49-
pc.baud(115200);
50-
pc.printf("Starting programme.\n");
54+
55+
char start_str[] = "Starting programme.\n";
56+
pc.write(start_str, strlen(start_str));
5157

5258
DevI2C i2c(I2C_SDA0, I2C_SCL0);
5359
// This is an open drain combined interrupt line, not used in this example
@@ -60,7 +66,8 @@ int main(void) {
6066
FXOS8700QAccelerometer accFxos(i2c, FXOS_ADDR);
6167
FXOS8700QMagnetometer magFxos(i2c, FXOS_ADDR);
6268
if ((accFxos.whoAmI() != 0xC7) || (magFxos.whoAmI() != 0xC7)) {
63-
pc.printf("Error reading the FXOS8700 Who Am I register.\n");
69+
char msg[] = "Error reading the FXOS8700 Who Am I register.\n";
70+
pc.write(msg, strlen(msg));
6471
for(;;);
6572
}
6673
accFxos.enable();
@@ -74,11 +81,13 @@ int main(void) {
7481
uint8_t whoAmIAccVal = 0;
7582
uint8_t whoAmIMagVal = 0;
7683
if ((magLsm.read_id(&whoAmIMagVal) != 0) || (whoAmIMagVal != 0x40)) {
77-
pc.printf("Error reading the LSM303 Mag Who Am I register.\n");
84+
char msg[] = "Error reading the LSM303 Mag Who Am I register.\n";
85+
pc.write(msg, strlen(msg));
7886
for(;;);
7987
}
8088
if ((accLsm.read_id(&whoAmIAccVal) != 0) || (whoAmIAccVal != 0x33)) {
81-
pc.printf("Error reading the LSM303 Acc Who Am I register.\n");
89+
char msg[] = "Error reading the LSM303 Acc Who Am I register.\n";
90+
pc.write(msg, strlen(msg));
8291
for(;;);
8392
}
8493
accLsm.init(NULL);
@@ -94,16 +103,16 @@ int main(void) {
94103
#ifdef FXOS_PRESENT
95104
accFxos.getAxis(accFxosData);
96105
magFxos.getAxis(magFxosData);
97-
pc.printf("FXOS Acc: [X:%d] [Y:%d] [Z:%d]\n", accFxosData.x, accFxosData.y, accFxosData.z);
98-
pc.printf("FXOS Mag: [X:%d] [Y:%d] [Z:%d]\n", magFxosData.x, magFxosData.y, magFxosData.z);
106+
printf("FXOS Acc: [X:%d] [Y:%d] [Z:%d]\n", accFxosData.x, accFxosData.y, accFxosData.z);
107+
printf("FXOS Mag: [X:%d] [Y:%d] [Z:%d]\n", magFxosData.x, magFxosData.y, magFxosData.z);
99108
#endif
100109
#ifdef LSM_PRESENT
101110
accLsm.get_x_axes(accLsmData);
102111
magLsm.get_m_axes(magLsmData);
103-
pc.printf("\nLSM Acc: [X:%d] [Y:%d] [Z:%d]\n", accLsmData[0], accLsmData[1], accLsmData[2]);
104-
pc.printf("LSM Mag: [X:%d] [Y:%d] [Z:%d]\n", magLsmData[0], magLsmData[1], magLsmData[2]);
112+
printf("\nLSM Acc: [X:%d] [Y:%d] [Z:%d]\n", accLsmData[0], accLsmData[1], accLsmData[2]);
113+
printf("LSM Mag: [X:%d] [Y:%d] [Z:%d]\n", magLsmData[0], magLsmData[1], magLsmData[2]);
105114
#endif
106-
pc.printf("---------\n");
115+
printf("---------\n");
107116
nrf_delay_ms(500);
108117
}
109118
}

examples/serial.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,19 @@
1616
*/
1717
#include "mbed.h"
1818

19-
int main(void) {
20-
Serial pc(USBTX, USBRX);
21-
pc.baud(115200);
22-
pc.printf("hello world!\n");
19+
static UnbufferedSerial pc_serial(USBTX, USBRX, 115200);
2320

24-
// Echo back
25-
while (true) {
26-
while (pc.readable()) {
27-
uint32_t val = pc.getc();
28-
pc.putc(val);
29-
}
21+
void rx_irq() {
22+
char single_byte;
23+
// Echo each byte received
24+
if (pc_serial.read(&single_byte, 1)) {
25+
pc_serial.write(&single_byte, 1);
3026
}
3127
}
28+
29+
int main(void) {
30+
char hello[] = "hello world!\n";
31+
size_t hello_size = sizeof(hello) / sizeof(hello[0]);
32+
pc_serial.write(hello, hello_size);
33+
pc_serial.attach(&rx_irq, SerialBase::RxIrq);
34+
}

mbed-os.lib

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://github.com/ARMmbed/mbed-os/#73f096399b4cda1f780b140c87afad9446047432
1+
https://github.com/ARMmbed/mbed-os/#d147abc3e556c58e5e343d34b729bc2192e18bd3

0 commit comments

Comments
 (0)