8000 Micropython 25ae98f merge by dhalbert · Pull Request #1068 · adafruit/circuitpython · GitHub
[go: up one dir, main page]

Skip to content

Micropython 25ae98f merge #1068

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 10000 terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 839 commits into from
Jul 30, 2018
Merged

Conversation

dhalbert
Copy link
Collaborator

This merges from micropython@25ae98f.

I did some REPL testing, and it passes the Unix tests (that took some work), but some hidden issues may show up. Atmel, esp8266, and nrf all compile and bring up the REPL.

Some notes:

  • Churn in extmod/vfs* : some files removed, some renamings. We exposed some statics for our use elsewhere, which means it was not a simple merge.
  • In MPy, lots of #ifdef -> #if, but without necessarily defining the variables, so I added `#define``s so they won't make warnings
  • In ESP8266, MPy generalized dupterm and used it to create even the initial UART. Had to undo this because multiterminal doesn't work like that.
  • Had to bring back drivers/bus after we deleted it because some code was using it.

dpgeorge and others added 30 commits May 2, 2018 12:17
This makes ADCAll work correctly on L4 MCUs.
The problem is the existing code which tries to optimise the
reinitialisation of the DMA breaks the abstraction of the HAL.  For the
STM32L4 the HAL's DMA setup code maintains two private vars (ChannelIndex,
DmaBaseAddress) and updates a hardware register (CCR).

In HAL_DMA_Init(), the CCR is updated to set the direction of the DMA.
This is a problem because, when using the SD Card interface, the same DMA
channel is used in both directions, so the direction bit in the CCR must
follow that.

A quick and effective fix for the L4 is to simply call HAL_DMA_DeInit() and
HAL_DMA_Init() every time.
For a given IRQn (eg UART) there's no need to carry around both a PRI and
SUBPRI value (eg IRQ_PRI_UART, IRQ_SUBPRI_UART).  Instead, the IRQ_PRI_UART
value has been changed in this patch to be the encoded hardware value,
using NVIC_EncodePriority.  This way the NVIC_SetPriority function can be
used directly, instead of going through HAL_NVIC_SetPriority which must do
extra processing to encode the PRI+SUBPRI.

For a priority grouping of 4 (4 bits for preempt priority, 0 bits for the
sub-priority), which is used in the stm32 port, the IRQ_PRI_xxx constants
remain unchanged in their value.

This patch also "fixes" the use of raise_irq_pri() which should be passed
the encoded value (but as mentioned above the unencoded value is the same
as the encoded value for priority grouping 4, so there was no bug from this
error).
In adcall.py the pyb module may not be imported, so use ADCAll directly.

In dac.py the DAC object now prints more info, so update .exp file.

In spi.py the SPI should be deinitialised upon exit, so the test can run a
second time correctly.
Disabling this saves around 6000 bytes of code space and gets the 512k
build fitting in the available flash again (it increased lately due to an
increase in the size of the ESP8266 SDK).
Add --init to the submodule update example, thus, all submodules get
initialised including the nested (--recursive) ones.  Without it there
might not be a submodule init.
If a socket is cleanly shut down by the peer then reads on this socket
should continue to return zero bytes.  The lwIP socket API does not have
this behaviour (it only returns zero once, then blocks on subsequent calls)
so this patch adds explicit checks and logic for peer closed sockets.
The order of function calls in an arithmetic expression is undefined and so
they must be written out as sequential statements.

Thanks to @dv-extrarius for reporting this issue, see issue adafruit#3690.
Using MP_STREAM_POLL_HUP for ERR_RST state follows how *nix handles this
case.
On this 32-bit arch there's no need to use the long version of the format
specifier.  It's only there to appease the compiler which checks the type
of the args passed to printf.  Removing the "l" saves a bit of code space.
Commit e269cab added a check that the
first argument to the to_bytes() method is an integer, and now uPy
follows CPython behaviour and raises a TypeError for this test.

Note: CPython checks the argument types before checking the number of
arguments, but uPy does it the other way around, so they give different
exception messages for this test, but still the same type, a TypeError.
dpgeorge and others added 17 commits June 20, 2018 16:26
Prior to this patch the QSPI driver assumed that the length of all data
reads and writes was a multiple of 4.  This patch allows any length.  Reads
are optimised for speed by using 32-bit transfers when possible, but writes
always use a byte transfer because they only use a single data IO line and
are relatively slow.
This patch adds support to mboot for programming external SPI flash.  It
allows SPI flash to be programmed via a USB DFU utility in the same way
that internal MCU flash is programmed.
Segments are separated by / and begin with the memory address.  This
follows how the ST DFU tool works.
These files can also be used for F723, F732 and F733 MCUs.
This and the previous 4 commits combined have change in code size of:

   bare-arm:   -92
minimal x86:  -544
   unix x64:  -544
unix nanbox:  -712
      stm32:  -116
     cc3200:  -128
    esp8266:  -348
      esp32:  -232
@dhalbert dhalbert requested a review from tannewt July 28, 2018 20:10
@jerryneedell
Copy link
Collaborator
jerryneedell commented Jul 29, 2018

I pulled this PR and loaded it on to a few boards for test:
CPX_crickit -- no issues
esp8266 - no issues - tested Iternect connection -- send data to Adafruit-IO - tested ampy read/write
nrf52 - feather52832 -- on first attempt I had several cases where the board would not exit the bootloader - after flashing. Tried multiple times. Then in order to provide documentation, I reverted to current master build - and reflashed bootloader and CP (used default SD=s132 SOFTDEV_VERSION=2.0.1)
this worked OK.
Rebuild with this PR -- same configuration - reflashed bootloader and CP it it worked this time!!.
I also buitl it with SOFTDEV_VERSION 5.0.0 and reflashed bootloader and CP and it also works fine.
Tested executing ble_scan.py -- no issues - tested a few servo operations

It's possible I had some mismatch between bootladers and CP builds - but it works now!

ampy work for ls, put , rm - get does not work, but that is a known issue
https://github.com/adafruit/ampy/issues/47

Also note that instructions for loading the bootloader to the feather52832 are out-dated on
https://github.com/adafruit/circuitpython/tree/master/ports/nrf/boards/feather52832

the command is shown as

$ make BOARD=feather52832 SERIAL=/dev/tty.SLAB_USBtoUART SOFTDEV_VERSION=5.0.0 boot-flash

but it should be

$ make BOARD=feather52832 SERIAL=/dev/tty.SLAB_USBtoUART SOFTDEV_VERSION=5.0.0 dfu-bootloader

here is how I ran it (on Linux)

jerryneedell@Ubuntu-Macmini:~/circuitpython_master/ports/nrf$ make BOARD=feather52832  SD=s132  SOFTDEV_VERSION=5.0.0 SERIAL=/dev/ttyUSB0 dfu-bootloader
Use make V=1, make V=2 or set BUILD_VERBOSE similarly in your environment to increase build verbosity.
nrfutil --verbose dfu serial --package boards/feather52832/bootloader/feather52_bootloader_5.0.0_s132_single.zip -p /dev/ttyUSB0 -b 115200
Upgrading target on /dev/ttyUSB0 with DFU package /home/jerryneedell/projects/adafruit_github/circuitpython_master/ports/nrf/boards/feather52832/bootloader/feather52_bootloader_5.0.0_s132_single.zip. Flow control is disabled, Dual bank mode
Starting DFU upgrade of type 3, SoftDevice size: 136360, bootloader size: 22744, application size: 0
Sending DFU start packet
Sending DFU init packet
Sending firmware file
#########################################################################################################################################################################################################################################################################################################################
Activating new firmware

DFU upgrade took 26.2996571064s
Device programmed.

@dhalbert
Copy link
Collaborator Author

Removed qemu build because it does only minimal testing and is building for Cortex-M3 architecture.

Travis is finally happy, so this is ready for review. Thanks!

Copy link
Member
@tannewt tannewt left a comment

Choose a reason for hiding this comment

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

Thank you so much for taking this on! I really appreciate it. One comment and then it'll be good to merge.

- ([[ -z "$TRAVIS_BOARD" ]] || (wget https://s3.amazonaws.com/adafruit-circuit-python/gcc-arm-embedded_7-2018q2-1~trusty1_amd64.deb && sudo dpkg -i gcc-arm-embedded*_amd64.deb))
- ([[ $TRAVIS_TEST != "qemu" ]] || (wget https://s3.amazonaws.com/adafruit-circuit-python/gcc-arm-embedded_7-2018q2-1~trusty1_amd64.deb && sudo dpkg -i gcc-arm-embedded*_amd64.deb))
Copy link
Member

Choose a reason for hiding this comment

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

Remove this whole line. This has it always download it when the line above covers the other cases.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Roger. Missed that overlap.

@tannewt tannewt merged commit a6d94b6 into adafruit:master Jul 30, 2018
@dhalbert dhalbert deleted the micropython-25ae98f-merge branch August 6, 2019 02:37
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.

0