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

stm32: Add support for PYBD boards #4669

Closed
wants to merge 48 commits into from

Conversation

@dpgeorge
Copy link
Member

commented Apr 3, 2019

This PR adds support for PYBD_SF2, PYBD_SF3 and PYBD_SF6 boards, including a CYW4343 WiFi driver.

I don't intend to merge this just yet, it needs a little more cleaning of some commits and features, and some of the minor changes merged first.

Until it's fully merged I intend to rebase this PR, so please be aware of that if you clone it.

dpgeorge added 24 commits Apr 3, 2019
Because this function may execute in a raised priority context, and Python
callbacks must execute at "thread" level.
Also supports auto-detection of USB interface, either HS or FS.
@dpgeorge dpgeorge added the port-stm32 label Apr 3, 2019
@dpgeorge dpgeorge referenced this pull request Apr 3, 2019
dpgeorge added 4 commits Apr 6, 2019
Also makes ap.config('essid') return str, not bytes (to be the same as
other ports).
Also, if default WPA2 fails then WPA will be attempted automatically.
@@ -93,6 +96,7 @@ endif

LDFLAGS = -nostdlib -L $(LD_DIR) $(addprefix -T,$(LD_FILES)) -Map=$(@:.elf=.map) --cref
LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
LIBS += cyw43/libcyw43.a

This comment has been minimized.

Copy link
@vsubbiah

vsubbiah Apr 18, 2019

Any reason why this is a library and not as source?

This comment has been minimized.

Copy link
@dpgeorge

dpgeorge Apr 18, 2019

Author Member

Most of it is a binary blob that's downloaded to the CYW4343. The rest is a small bit of glue that talks to the CYW4343 through the SDMMC bus, and needs to be released as a binary to comply with the Cypress licensing.

This comment has been minimized.

Copy link
@vsubbiah

vsubbiah Jul 23, 2019

First I glad we have the binary version at least. Thanks to the authors. I would be nice to have the glue logic as source. Cypress has released an apace licensed version of WWD driver https://github.com/cypress/wwd. This has the glue logic.

This comment has been minimized.

Copy link
@dpgeorge

dpgeorge Jul 25, 2019

Author Member

Thanks for the link to the Cypress repo, that's really great news that they have released it like that! So I think then we can make this glue logic open source. I will look into it.

This comment has been minimized.

Copy link
@kvvd-packetp

kvvd-packetp Jul 29, 2019

Hi Damien George,
I am trying flash the mpy on PYBD-SF3-W4F2. I got the build successful and generated the *.dfu. But unable to get the board into DFU mode for flashing the image. Could please provide me a pointer on this?

Thanks for the help,
KVVD

This comment has been minimized.

Copy link
@kvvd-packetp

kvvd-packetp Jul 29, 2019

@ Damien George,
Continuing my previous post. Steps followed to get the board into DFU mode:

  1. connect 3v3 pin with boot0 pin.
  2. Press reset button on the board
  3. Check if the device is listed using "dfu-tool watch" or "dfu-util -l".
    But no luck. Empty list is printed on the screen.

This comment has been minimized.

Copy link
@jimmo

jimmo Jul 29, 2019

Contributor

@kvvd-packetp

http://micropython.org/download has the instructions for getting into the bootloader for the pybd.

The background here is that pybd uses its own bootloader (mboot) which has more features than the built-in ST bootloader (mainly it has the ability to write to external flash, so that the dfu file can flash both the on-chip flash as well as the external qspiflash). It's triggered by the process described above.

The likely reason the ST bootloader (which is what you're getting with the boot0 pin) isn't working for you is that it uses the other USB interface (which is accessible on the WBUS-DIP28 board), but either way you won't be able to flash a .dfu file built for the pybd using it.

This comment has been minimized.

Copy link
@kvvd-packetp

kvvd-packetp Jul 29, 2019

Thanks a lot for the update. I am able to get the board into dfu mode.

// Disable IRQs so that the IRQ that wakes the device from stop mode is not
// executed until after the clocks are reconfigured
uint32_t irq_state = disable_irq();

#if defined(MICROPY_HW_QSPIFLASH_SIZE_BITS_LOG2)
mp_spiflash_deepsleep(&spi_bdev.spiflash, 1);
mp_spiflash_deepsleep(&spi_bdev2.spiflash, 1);

This comment has been minimized.

Copy link
@andrewleech

andrewleech Apr 23, 2019

Contributor

This assumes spi_bdev2 exists so will break on older board definitions that only have one spi flash defined

This comment has been minimized.

Copy link
@dpgeorge

dpgeorge Apr 23, 2019

Author Member

Yes. This needs to be configured better, at the moment it's just there so it works.

This comment has been minimized.

Copy link
@andrewleech

andrewleech Apr 23, 2019

Contributor

👍 just a minor thing I saw, thought was worth noting as reminder for later! Looking fantastic in general though!

This comment has been minimized.

Copy link
@dpgeorge

dpgeorge Apr 23, 2019

Author Member

Yeah, thanks. There are a few other things like this that need cleaning up, eg the fixes to QSPI and the MPU.

@miketeachman miketeachman referenced this pull request May 16, 2019
4 of 4 tasks complete
@dpgeorge dpgeorge referenced this pull request May 29, 2019
11 of 16 tasks complete
@dpgeorge

This comment has been minimized.

Copy link
Member Author

commented Jun 3, 2019

Board definition files were added to master in 8f55c74

Support for WiFi was added to master in 62fe47a

@dpgeorge

This comment has been minimized.

Copy link
Member Author

commented Jul 3, 2019

QSPI MPU fixes were done in 8da39fd and caabdd9

As of commit 3581dee pretty much everything in this PR is now in master, in one form or another, in most cases cleaned up and improved. The only commit from here that is not in master is the one adding (via symlink) a bunch of networking modules as frozen bytecode 87a9e99 . Eventually this will be done but for now it's easy enough to just add needed scripts to the filesystem.

@dpgeorge dpgeorge closed this Jul 3, 2019
@robert-hh

This comment has been minimized.

Copy link
Contributor

commented Jul 3, 2019

I just tried the master branch with a SF6 and SF2 module. At first glance, the only thing that is missing is support for the MMC. This little script fails, obviously at line 2:

import os, pyb
os.mount(pyb.MMCard(), '/mmc')
@dpgeorge

This comment has been minimized.

Copy link
Member Author

commented Jul 3, 2019

@robert-hh thanks for testing, indeed the MMC doesn't work with that snippet.

What changed is that Pin('EN_3V3') is no longer turned on by default, and so there's no power to the MMC. The reason for not turning it on is that the user application needs full control over this 3V3 power rail, eg coming out of deepsleep the 3V3 rail should remain off until the script knows it wants to power up the peripherals.

So this should work:

machine.Pin('EN_3V3', machine.Pin.OUT, value=1)
os.mount(pyb.MMCard(), '/mmc')

But I think what should be changed here is that EN_3V3 be automatically turned on if the MMCard object is initialised, because there's not much point in initialising it without power.

@robert-hh

This comment has been minimized.

Copy link
Contributor

commented Jul 3, 2019

Thanks. That worked.

@dpgeorge

This comment has been minimized.

Copy link
Member Author

commented Jul 4, 2019

In 1cd2bc0 pin EN_3V3 is automatically configured as an output on boot (but still remains off). And in c1a8c7f EN_3V3 is automatically turned on when SD/MMC are powered on.

So now os.mount(pyb.MMCard(), '/mmc') should just work without any extra code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.