aboutsummaryrefslogtreecommitdiff
path: root/stmhal/sdcard.c
AgeCommit message (Collapse)Author
2017-09-06ports: Make new ports/ sub-directory and move all ports there.Damien George
This is to keep the top-level directory clean, to make it clear what is core and what is a port, and to allow the repository to grow with new ports in a sustainable way.
2017-08-29stmhal: Update to new STM Cube HAL library.Damien George
This upgrades the HAL to the versions: - F4 V1.16.0 - F7 V1.7.0 - L4 V1.8.1 The main changes were in the SD card driver. The vendor changed the SD read/write functions to accept block number intead of byte address, so there is no longer any need for a custom patch for this in stm32lib. The CardType values also changed, so pyb.SDCard().info() will return different values for the 3rd element of the tuple, but this function was never documented.
2017-07-31all: Use the name MicroPython consistently in commentsAlexander Steffen
There were several different spellings of MicroPython present in comments, when there should be only one.
2017-07-19all: Remove trailing spaces, per coding conventions.Damien George
2017-06-27stmhal/sdcard: Allow a board to customise the SDIO pins.Benjamin Weps
2017-05-06stmhal: Convert all module and method tables to use MP_ROM macros.Damien George
2017-03-30stmhal/sdcard: Add support for SDMMC2 on F7 MCUs.Damien George
By default the SDIO (F4) or SDMMC1 (L4, F7) is used as the SD card peripheral, but if a board config defines MICROPY_HW_SDMMC2_CK and other pins then the SD card driver will use SDMMC2.
2017-03-02stmhal: Rename sys_tick ticks/delay functions to corresp. mp_hal ones.Damien George
The renames are: HAL_Delay -> mp_hal_delay_ms sys_tick_udelay -> mp_hal_delay_us sys_tick_get_microseconds -> mp_hal_ticks_us And mp_hal_ticks_ms is added to provide the full set of timing functions. Also, a separate HAL_Delay function is added which differs slightly from mp_hal_delay_ms and is intended for use only by the ST HAL functions.
2017-03-02stmhal: Use mp_hal_delay_ms instead of HAL_Delay.Damien George
2017-01-31stmhal: On boot, mount all available partitions of the SD card.Damien George
The first partition is mounted as "/sd" and subsequent partitions are mounted as "/sd<part_num>". This is backwards compatible with the previous behaviour, which just mounted the first partition on "/sd". At this point, only FatFs filesystems are mounted.
2017-01-30stmhal: Set the FatFs partition number when initialising VFS object.Damien George
stmhal has MULTI_PARTITION enabled for FatFs and so these values need to be initialised.
2017-01-30extmod: Merge old fsusermount.h header into vfs.h and vfs_fat.h.Damien George
vfs.h is for generic VFS declarations, and vfs_fat.h is for VfsFat specific things.
2017-01-27stmhal: Convert to use VFS sub-system and new ooFatFs component.Damien George
This patch makes the following configuration changes: - MICROPY_FSUSERMOUNT is disabled, removing old mounting infrastructure - MICROPY_VFS is enabled, giving new VFS sub-system - MICROPY_VFS_FAT is enabled, giving uos.VfsFat type - MICROPY_FATFS_OO is enabled, to use new ooFatFs lib, R0.12b User facing API should be almost unchanged. Most notable changes are removal of os.mkfs (use os.VfsFat.mkfs instead) and pyb.mount doesn't allow unmounting by passing None as the device.
2016-12-22stmhal/sdcard: Use mp_hal_pin_config function instead of HAL_GPIO_Init.Damien George
There is a minor functional change with this patch, that the GPIO are now configured in fast mode, whereas they were in high speed mode before. But the SDIO should still work because SD CK frequency is at most 25MHz.
2016-12-02stmhal/sdcard: Clean/invalidate cache before DMA transfers with SD card.Jean-François Milants
Add 2 macros in mphalport.h that clean and invalidate data caches only on STM32F7 MCUs. They are needed to ensure the cache coherency before/after DMA transferts. * MP_HAL_CLEANINVALIDATE_DCACHE cleans and invalidate the data cache. It must be called before starting a DMA transfer from the peripheral to the RAM memory. * MP_HAL_CLEAN_DCACHE cleans the data cache. It must be called before starting a DMA transfert from the RAM memory to the peripheral. These macros are called in sdcard.c, before reading from and writing to the SDCard, when DMA is used.
2016-11-07stmhal: enable SD power save (disable CLK on idle)Ryan Shaw
2016-06-29stmhal: Enable SD card on L4 MCUs.dpslwk
2016-05-13stmhal/sdcard: Allow to do unaligned read-from/write-to SD card.Damien George
For example, the following code now works with a file on the SD card: f = open('test', 'rb') # test must be 1024 bytes or more in size f.seek(511) f.read(513) Also works for writing. Fixes issue #1863.
2016-05-06stmhal/sdcard: Fix initialisation of DMA TX so that writes work.Damien George
Addresses issue #2034.
2016-05-05stmhal: L4: Adapt DMA to be able to support STM32L4 MCU series.Tobias Badertscher
The main thing is to change the DMA code in a way that the structure DMA_Stream_TypeDef (which is similar to DMA_Channel_TypeDef on stm32l4) is no longer used outside of dma.c, as this structure only exists for the F4 series. Therefore I introduced a new structure (dma_descr_t) which handles all DMA specific stuff for configuration. Further the periphery (spi, i2c, sdcard, dac) does not need to know the internals of the dma.
2016-02-10extmod/fsusermount: Move BP_IOCTL_xxx constants to fsusermount.h.Damien George
2016-02-10extmod/fsusermount: Support mounting of multiple block devices.Damien George
This patch adds support to fsusermount for multiple block devices (instead of just one). The maximum allowed is fixed at compile time by the size of the fs_user_mount array accessed via MP_STATE_PORT, which in turn is set by MICROPY_FATFS_VOLUMES. With this patch, stmhal (which is still tightly coupled to fsusermount) is also modified to support mounting multiple devices And the flash and SD card are now just two block devices that are mounted at start up if they exist (and they have special native code to make them more efficient).
2016-02-10stmhal: Expose flash and SD card as proper objects with block protocol.Damien George
You can now create (singleton) objects representing the flash and SD card, using: flash = pyb.Flash() sdcard = pyb.SDCard() These objects provide the block protocol.
2015-12-22stmhal: Add pyb.irq_stats() to get statistics about IRQ calls.Damien George
Adds a lot of code, makes IRQs a bit less efficient, but is very useful for debugging. Usage: pyb.irq_stats() returns a memory view that can be read and written, eg: list(pyb.irq_stats()) pyb.irq_stats()[0] pyb.irq_stats()[0] = 0 The patch provides general IRQ_ENTER() and IRQ_EXIT() macros that can be modified to provide further IRQ statistics if desired.
2015-12-04stmhal: Protect SD card DMA transactions against USB MSC contention.Damien George
Consider the following scenario: SD card is being read by pyboard; USB irq comes in for MSC read request; SD card needs to be read from within USB irq while SD read is already ongoing. Such contention needs to be avoided. This patch provides a simple solution, to raise the irq priority above that of the USB irq during SD DMA transfers. Pyboard and PC can now read from the SD card at the same time (well, reads are interleaved).
2015-11-24stmhal: Save RAM and ROM by making SD DMA init structure const for tx/rx.Damien George
2015-11-24stmhal: Add dma support for sdcard.Dave Hylands
This started out using IgorLektorovEpam work in PR #1389 and reworked it.
2015-10-30stmhal: Enable sdcard on STM32F7DISC board.Dave Hylands
2015-10-11py: Rename MP_BOOL() to mp_obj_new_bool() for consistency in naming.Paul Sokolovsky
2015-07-30stmhal: Replace #include "stm32f4xx_hal.h" with #include STM32_HAL_H.Dave Hylands
2015-03-20stmhal: Remove some unnecessary declarations, purely for cleanup.Damien George
2015-02-27py: Use m_{new,renew,del} consistently.Damien George
This is so all memory requests go through the same interface.
2015-01-01stmhal: Prefix includes with py/; remove need for -I../py.Damien George
2014-10-20stmhal: Add retry to SD card init.Damien George
This fixed an issue with a certain SD card sometimes not initialising first time round. See issue #822 for related, and thanks to @iabdalkader for the idea.
2014-09-15stmhal: Change 64-bit arithmetic to 32-bit for SD card block addressing.Damien George
By measuring SD card addresses in blocks and not bytes, one can get away with using 32-bit numbers. This patch also uses proper atomic lock/unlock around SD card read/write, adds SD.info() function, and gives error code for failed read/writes.
2014-09-15stmhal/sdcard.c: add pyb.SD.writeFelix Domke
2014-08-25Fix sdcard_power_on to not do anything if the card is already powered on.Dave Hylands
2014-07-07stmhal: Protect SD_WriteBlocks by IRQ disable/enable pair.Damien George
2014-07-06Disable IRQs around sdcard reads.Dave Hylands
Once the code switches to using DMA, this can be removed.
2014-06-28stmhal: Include mpconfig.h before all other includes.Paul Sokolovsky
It defines types used by all other headers. Fixes #691.
2014-05-03Add license header to (almost) all files.Damien George
Blanket wide to all .c and .h files. Some files originating from ST are difficult to deal with (license wise) so it was left out of those. Also merged modpyb.h, modos.h, modstm.h and modtime.h in stmhal/.
2014-04-17build: Simplify build directory layout by putting all headers in genhdr.Damien George
Any generated headers go in $(BUILD)/genhdr/, and are #included as 'genhdr/xxx.h'.
2014-03-30Merge map.h into obj.h.Damien George
Pretty much everyone needs to include map.h, since it's such an integral part of the Micro Python object implementation. Thus, the definitions are now in obj.h instead. map.h is removed.
2014-03-30Rename rt_* to mp_*.Damien George
Mostly just a global search and replace. Except rt_is_true which becomes mp_obj_is_true. Still would like to tidy up some of the names, but this will do for now.
2014-03-30stmhal: Unify naming of HW config; make SD detect configurable.Damien George
All board config macros now begin with MICROPY_HW_. Renamed PYBv10 to PYBV10, since macros should be all uppercase. Made SDCARD_DETECT configurable in mpconfigport.h, so that the SD detect pin can be easily configured.
2014-03-26Remove mp_obj_type_t.methods entry and use .locals_dict instead.Damien George
Originally, .methods was used for methods in a ROM class, and locals_dict for methods in a user-created class. That distinction is unnecessary, and we can use locals_dict for ROM classes now that we have ROMable maps. This removes an entry in the bloated mp_obj_type_t struct, saving a word for each ROM object and each RAM object. ROM objects that have a methods table (now a locals_dict) need an extra word in total (removed the methods pointer (1 word), no longer need the sentinel (2 words), but now need an mp_obj_dict_t wrapper (4 words)). But RAM objects save a word because they never used the methods entry. Overall the ROM usage is down by a few hundred bytes, and RAM usage is down 1 word per user-defined type/class. There is less code (no need to check 2 tables), and now consistent with the way ROM modules have their tables initialised. Efficiency is very close to equivaluent.
2014-03-26Change mp_method_t.name from const char * to qstr.Damien George
Addresses issue #377.
2014-03-17stmhal: Add SD card support.Damien George
Just low-level read/write support. No filesystem yet.