stm32 NUCLEO boards: pin name conflicts
On pyboard:
>>> import pyb
>>> pin = pyb.Pin('A2')
>>> pin
Pin(Pin.cpu.A2, mode=Pin.ALT, pull=Pin.PULL_UP, af=Pin.AF7_USART2)
On many NUCLEO boards:
>>> import pyb
>>> pin = pyb.Pin('A2')
>>> pin
Pin(Pin.cpu.A4, mode=Pin.ANALOG)
On NUCLEO boards (eg NUCLEO_F091RC or L476RG) 'A2' maps to cpu pin A4.
This is because pins.csv has a board pin entry 'A2' for the Arduino analog pin name. Quite a few of the Arduino pin names are the same as the STM32 port names.
I can think of 4 solutions:
- Remove the Arduino pin names from pins.csv.
- Prepend the Arduino name with something, eg connector name -
CN8_A2 - Require cpu pins to be entered with a P, eg
pyb.Pin('PA2'). - Require cpu pins to be entered with a
cpu.prefix, egpyb.Pin('cpu.A2').
Options 3 & 4 are most likely to break existing code, although this could be avoided by mapping the short names in the csv file, eg A2,PA2 or A2,cpu.A2, for non NUCLEO ports.
Option 3 may not work for all MCUs as some MCUs don't have a P, just A2, etc.
I am currently using option 2, ie make board pin names unique.
Any suggestions on the best fix?
tests/pyb/adcall.py: fails on NUCLEO_F411RE and hang board
Multiple tests in the pyb directory fail on a NUCLEAO_F411RE:
- The pyb/adcall.py has hard-coded pins, some of which (A2&A3) overlap with the uart used for the REPL. This causes the test to fail and the board to become unresponsive to pyboard/run-tests.
- 6 tests failed: extint pin pyb1 rtc servo uart
FAILURE pyb_extint.py
--- pyb_extint.py.exp 2020-04-15 08:45:44.599717251 -0700
+++ pyb_extint.py.out 2020-04-15 08:45:44.599717251 -0700
@@ -1,3 +1,4 @@
-4
-line: 4
-line: 4
+Traceback (most recent call last):
+ File "<stdin>", line 4, in <module>
+ValueError: Pin(X5) doesn't exist
+CRASH
\ No newline at end of file
FAILURE pyb_pin.py
--- pyb_pin.py.exp 2020-04-15 08:45:53.849714608 -0700
+++ pyb_pin.py.out 2020-04-15 08:45:53.849714608 -0700
@@ -1,14 +1,4 @@
-Pin(Pin.cpu.A7, mode=Pin.IN)
-A7
-7
-0
-Pin(Pin.cpu.A7, mode=Pin.IN, pull=Pin.PULL_UP)
-1
-Pin(Pin.cpu.A7, mode=Pin.IN, pull=Pin.PULL_DOWN)
-0
-0
-1
-0
-1
-0
-1
+Traceback (most recent call last):
+ File "<stdin>", line 3, in <module>
+ValueError: Pin(X8) doesn't exist
+CRASH
\ No newline at end of file
FAILURE pyb_uart.py
--- pyb_uart.py.exp 2020-04-15 08:45:56.709713791 -0700
+++ pyb_uart.py.out 2020-04-15 08:45:56.709713791 -0700
@@ -1,20 +1,10 @@
ValueError -1
ValueError 0
-UART 1
-UART 2
+ValueError 1
+ValueError 2
ValueError 5
UART 6
-UART(1, baudrate=9600, bits=8, parity=None, stop=1, flow=0, timeout=0, timeout_char=3, rxbuf=64)
-UART(1, baudrate=2400, bits=8, parity=None, stop=1, flow=0, timeout=0, timeout_char=7, rxbuf=64)
-0
-3
-4
-None
-1
-4
-None
-None
-UART(1, baudrate=9600, bits=8, parity=None, stop=1, flow=0, timeout=0, timeout_char=3, rxbuf=8)
-UART(1, baudrate=9600, bits=8, parity=None, stop=1, flow=0, timeout=0, timeout_char=3, rxbuf=0)
-UART(1, baudrate=9600, bits=8, parity=None, stop=1, flow=0, timeout=0, timeout_char=3, rxbuf=4)
-UART(1, baudrate=9600, bits=8, parity=None, stop=1, flow=0, timeout=0, timeout_char=3, rxbuf=0)
+Traceback (most recent call last):
+ File "<stdin>", line 11, in <module>
+ValueError: UART(1) doesn't exist
+CRASH
\ No newline at end of file
FAILURE pyb_pyb1.py
--- pyb_pyb1.py.exp 2020-04-15 08:45:54.039714554 -0700
+++ pyb_pyb1.py.out 2020-04-15 08:45:54.039714554 -0700
@@ -1,4 +1,6 @@
3
3
-True
-12
+Traceback (most recent call last):
+ File "<stdin>", line 30, in <module>
+AttributeError: 'module' object has no attribute 'have_cdc'
+CRASH
\ No newline at end of file
FAILURE pyb_servo.py
--- pyb_servo.py.exp 2020-04-15 08:45:55.849714036 -0700
+++ pyb_servo.py.out 2020-04-15 08:45:55.849714036 -0700
@@ -1,3 +1,4 @@
-<Servo 1 at 1500us>
-1500
-(630, 2410, 1490, 2460, 2190)
+Traceback (most recent call last):
+ File "<stdin>", line 1, in <module>
+ImportError: cannot import name Servo
+CRASH
\ No newline at end of file
FAILURE pyb_rtc.py
--- pyb_rtc.py.exp 2020-04-15 08:45:55.739714068 -0700
+++ pyb_rtc.py.out 2020-04-15 08:45:55.739714068 -0700
@@ -1,5 +1,5 @@
<RTC>
-(2014, 1, 1, 1, 0, 0, 1)
+(2014, 1, 1, 1, 0, 0, 0)
(2000, 1, 1, 1, 0, 0, 0)
(2000, 1, 31, 1, 0, 0, 0)
(2000, 12, 31, 1, 0, 0, 0)