8000 stm32: Add support for PYBD boards by dpgeorge · Pull Request #4669 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

stm32: Add support for PYBD boards #4669

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

Closed
wants to merge 48 commits into from

Conversation

dpgeorge
Copy link
Member
@dpgeorge dpgeorge 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 April 3, 2019 18:41
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 mentioned this pull request Apr 3, 2019
@@ -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

Choose a reason for hiding this comment

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

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

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

Choose a reason for hiding this comment

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

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.

Copy link
Member Author

Choose a reason for hiding this comment

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

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.

Choose a reason for hiding this comment

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

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

Choose a reason for hiding this comment

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

@ 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.

Copy link
Member

Choose a reason for hiding this comment

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

@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.

Choose a reason for hiding this comment

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

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

Copy link

Choose a reason for hiding this comment

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

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

@dpgeorge Any plans on releasing this as open source. If there is a project plan for this, I would love to contribute!

Copy link
Member

Choose a reason for hiding this comment

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

@vs-pp
This just happened last week -- the driver is now dual-licensed (free for non-commercial or with Raspberry Pi devices, commercial licensing on request). See https://github.com/georgerobotics/cyw43-driver

// 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);
Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Member Author

Choose a reason for hiding this comment

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

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

Copy link
Contributor

Choose a reason for hiding this comment

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

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

Copy link
Member Author

Choose a reason for hiding this comment

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

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

@dpgeorge
Copy link
Member Author
dpgeorge commented Jun 3, 2019

Board definition files were added to master in 8f55c74

Support for WiFi was added to master in 62fe47a

@dpgeorge
Copy link
Member Author
dpgeorge 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
Copy link
Contributor

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
Copy link
Member Author
dpgeorge 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
Copy link
Contributor

Thanks. That worked.

@dpgeorge
Copy link
Member Author
dpgeorge 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.

@dpgeorge dpgeorge deleted the stm32-pybd branch July 12, 2022 04:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants
0