aboutsummaryrefslogtreecommitdiff
path: root/src/flash/nor
AgeCommit message (Collapse)AuthorFilesLines
2021-12-03flash/nor/fespi: algorithm, large address, errorsTim Newsome1-327/+148
* Move more smarts into the target algorithm code, and rewrite that in C so it's easier to understand/maintain. * Support >24-bit addresses. * Check for errors. Change-Id: I3b1a143589fe6defafb8f95820aa682acc9646e7 Signed-off-by: Tim Newsome <tim@sifive.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6679 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-12-03flash/nor/at91samd: remove 'at91samd info' commandTomas Vanek1-13/+0
The command is a stub only, does nothing. Change-Id: Ib3b8c2122a9f6f2e179bee34ac56d0adf367bfcc Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6730 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-12-03flash/nor/kinetis_ke: remove 'kinetis mdm test_securing' cmdTomas Vanek1-40/+0
The command might be a leftover from development of the driver. There is no documentation what it does. Change-Id: Iaa5aa1ac51638bd6acce172a5dd03846a165dc27 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6728 Tested-by: jenkins Reviewed-by: Ivan-Artekit <ivan@artekit.eu>
2021-12-03flash/nor/kinetis_ke: add .help fields for tcl commandsTomas Vanek1-4/+4
Add help texts from similar driver kinetis.c While on it fix one existing help: the flash is obviously not NAND Change-Id: Ibd295105586b008aaabf2fb4e4a75bf551266e38 Signed-off-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-on: https://review.openocd.org/c/openocd/+/6727 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-11-29flash/nor/efm32: fixed BG1x identificationDoug Brunner1-3/+3
The EFM32 flash driver misidentifies the EFR32BG1B on my board as EFR32MG1B. Looks like this was caused by a copy-paste error, fixed. Signed-off-by: Doug Brunner <doug.a.brunner@gmail.com> Change-Id: I3067f7ba132c2562487da8c2371f63a4843230c1 Reviewed-on: https://review.openocd.org/c/openocd/+/6666 Tested-by: jenkins Reviewed-by: Fredrik Hederstierna <fredrik.hederstierna@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-11-23flash/psoc6: initialize usage fieldAntonio Borneo1-1/+1
The missing initialization triggers a run-time error message: Error: BUG: command 'psoc6 reset_halt' does not have the '.usage' field filled out Change-Id: I975e4ba99bd939aa924a9d62b1ab76b2ab5bf193 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6720 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-11-23flash/rp2040: don't initialize to NULL fields in structAntonio Borneo1-1/+0
When a struct is initialized, missing fields are already filled with zero or NULL. This change simplifies scripts to compare documentation and registered commands. Change-Id: I96fbdfa98bbb1f2b5e2a9532faf5a15cb5bc28dd Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6719 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-11-23openocd: use unique name for struct command_registrationAntonio Borneo3-12/+12
Just to avoid name clash when comparing documentation with registered commands through scripts. Change-Id: I8832545d8d9236ea5dabe6e73732f51e5246caff Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6717 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2021-11-23openocd: use single line for register_commands*()Antonio Borneo1-2/+1
Do not split in multiple lines the calls to register_commands*(). No change in code behaviour, just make it easy to grep in the code and identify the commands that can be registered. This would help detecting undocumented commands. Change-Id: Id654e107cdabf7ee31fc3d227c1d2a59acc5669e Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6716 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-11-18flash/nor/at91samd: Add SAMR35J18B supportJanco Kock1-0/+1
Add support for the mcu SAMR35J18B Signed-off-by: Janco <janco@factorylab.nl> Change-Id: I45d801485ad1c16d1b3086516a2b6d71d13f3fc7 Reviewed-on: https://review.openocd.org/c/openocd/+/6664 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2021-11-15flash/nor/stm32f1x: Add support for GD32E23xasier701-2/+17
GD32E23x from GigaDevice is cortex-M23 microcontroller and it can work with the stm32f1x driver. Modifications are similar to this done for GD32F1x0 in #6164 (https://review.openocd.org/c/openocd/+/6164). Configuration file is added because its cortex-M23 CPU ID is different. I think that GigaDevice microcontrollers should be handled in an independent unit to separate them from STM32, but nowadays quick solution is welcome. Signed-off-by: asier70Andrzej Sierżęga <asier70@gmail.com> Change-Id: I91f31f5f66808bc50a8f607ac2c107e6b7c5e2b8 Reviewed-on: https://review.openocd.org/c/openocd/+/6527 Tested-by: jenkins Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-11-13jtagspi: fix build on MacOSAntonio Borneo1-2/+2
Commit be57b0ab847e ("Update jtagspi driver for 1-, 2- and 4-byte addresses") introduces two incorrect format string for uint32_t data types. This cause build failure on MacOS: src/flash/nor/jtagspi.c:474:35: error: format specifies type 'unsigned char' but the argument has type 'uint32_t' (aka 'unsigned int') [-Werror,-Wformat] LOG_DEBUG("status=0x%02" PRIx8, *status); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~ src/flash/nor/jtagspi.c:513:65: error: format specifies type 'unsigned char' but the argument has type 'uint32_t' (aka 'unsigned int') [-Werror,-Wformat] LOG_ERROR("Cannot enable write to flash. Status=0x%02" PRIx8, status); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~ Fix the format string. Change-Id: I209053317c8b26c35c6f11be0553ccccc698c551 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Fixes: be57b0ab847e ("Update jtagspi driver for 1-, 2- and 4-byte addresses") Reviewed-on: https://review.openocd.org/c/openocd/+/6701 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2021-11-13flash/stm32h7x: don't read flash size using the H74/H75x CPU2Tarek BOCHKATI1-6/+11
CPU2 (Cortex-M4) cannot read flash size register. assume the maximum flash size without triggering an error message Change-Id: I5c3328b7cc42e3aa57165075021227d7936f3d26 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6670 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-11-13flash/stm32h7x: avoid using magic numbers for device idsTarek BOCHKATI1-20/+25
Change-Id: I4d682ee828404974abd9a42f98b840d77835cfe0 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6669 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2021-11-12Update jtagspi driver for 1-, 2- and 4-byte addressesAndreas Bolsch1-90/+443
jtagspi driver always used 3-byte addresses regardless of actual device capcity. Now select 1- to 4-byte addresses depending on device capacity. Some devices need a special command to activate the 4-byte address mode, a special command to accomplish this, and a further command for setting device properties are added. Additionally, restriction (start of range had to be page aligned) removed. Tested with XCS6SLX16 board and W25Q256FV in 3- and 4-byte address modes. Change-Id: I88b2877517a18dac460253ae6d97f3dded054e6c Signed-off-by: Andreas Bolsch <hyphen0break@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/4876 Reviewed-by: Jan Matyas <matyas@codasip.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: zapb <dev@zapb.de> Tested-by: jenkins
2021-11-03flash/nor/stm32lx: fixed writes at high adapter speedsJimmy1-4/+21
The busy flag must be polled after each half-page write. At low clock speeds, no issue is observed when the poll is omitted, because the writes complete before the next write begins. But at high clock speeds the subsequent writes would overlap and cause the operation to fail. The status polls are done on the target for efficiency, since the half-pages are very small. Change-Id: Ia1e9b4a6a71930549b3d84a902744ce6e596301b Signed-off-by: Jimmy <nhminus@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/5598 Tested-by: jenkins Reviewed-by: Jelle De Vleeschouwer Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Andrzej Sierżęga <asier70@gmail.com>
2021-10-25flash/nor/psoc6: fix doxygen commentAntonio Borneo1-2/+1
Commit 64c2e03b23d9 ("flash/nor: improved API of flash_driver.info & fixed buffer overruns") changes the prototype of the function psoc6_get_info() but didn't update the list of parameters in the doxygen comment. Fix the doxygen comment. Change-Id: I1dce018b60d080973c5e351490d4d7baba422d74 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Fixes: 64c2e03b23d9 ("flash/nor: improved API of flash_driver.info & fixed buffer overruns") Reviewed-on: https://review.openocd.org/c/openocd/+/6620 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2021-10-02helper: Remove src/helper from include dirsYasushi SHOJI2-3/+3
The header files under src/helper/ can currently be included with either #include <bits.h> or #include <helper/bits.h> This is because we specify both "src/" and "src/helper/" directories as include directories. Some files name under "src/helper/", such as types.h, log.h, and util.h are too generic and could be ambiguous depending on the search path. This commit remove "src/helper/" from our include dir and make C files include explicitly. Change-Id: I38fc9b96ba01a513d4a72757d40007e21b502f25 Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6507 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-09-25armv7m.h: relax dependency from 'arm_adi_v5.h'Antonio Borneo14-0/+14
The include file 'armv7m.h' includes 'arm_adi_v5.h' only to get the definition of 'struct adiv5_ap', but doesn't need the struct content. Reducing the cross dependencies speeds-up the compile time during code development by avoiding re-compiling file. Relax the dependency by locally declaring 'struct adiv5_ap' in 'armv7m.h' and remove the include of 'arm_adi_v5.h'. Fix the other files that have now lost the includes file that 'arm_adi_v5.h' depends from. Change-Id: Ic0d40b17db6045fa43f348bda83eaf211a6b347d Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6468 Tested-by: jenkins Reviewed-by: Daniel Goehring <dgoehrin@os.amperecomputing.com> Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com>
2021-09-18Partially Revert "flash/stm32l4x: introduce flash programming without loader"Oleksij Rempel1-41/+13
This partially reverts commit 1247eee4e6e5. There is no reasonable use cases where work-area should be enabled and working, and it can't be used for the flash loader. Instead of introducing driver specific property, users can disable flash load by disabling work-area, for example by setting it to 0. But still we keep the function stm32l4_write_block_without_loader to be used when workarea is not available (no sufficient size or zero) Change-Id: Ibb046c74df354c6067bac978e8ef7efb47d9fd2b Signed-off-by: Oleksij Rempel <linux@rempel-privat.de> Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6569 Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Tested-by: jenkins
2021-09-18flash/stm32l4x: fix dual bank support for STM32L552xC devicesTarek BOCHKATI1-3/+5
For STM32L552xC devices with 256K flash: dual bank mode is activated if DB256 is set page size is 2KB if DBANK is set For parts with 512K (aka STM32L5x2xE): DBANK controls both of dual/single bank mode and page size as well. Change-Id: I8be668d5552fefe81acffaf2e3e35ef5e938162e Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reported-by: Patrik Bachan <diggit@users.sourceforge.net> Fixes: https://sourceforge.net/p/openocd/tickets/317/ Reviewed-on: https://review.openocd.org/c/openocd/+/6538 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-09-12flash/stm32l4x: fix flash programming in 64-bit hostsTarek BOCHKATI2-3/+21
stm32l4_work_area struct is shared between the loader and stm32l4x flash driver '*wp' and '*rp' pointers' size is 4 bytes each since stm32l4x devices have 32-bit processors. however when used in openocd code, their size depends on the host if the host is 32-bit, then the size is 4 bytes each. if the host is 64-bit, then the size is 8 bytes each. to avoid this size difference, change their types depending on the usage (pointers for the loader, and 32-bit integers in openocd code). Change-Id: I0a3df4bb4bf872b01cdb9357eb28307868d7d469 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6556 Tested-by: jenkins Reviewed-by: Yestin Sun <sunyi0804@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz>
2021-09-11flash/stm32l4x: do not use magic number for dual bank option bitsTarek BOCHKATI2-17/+25
Change-Id: I27211e7d44b48f65546e31710ec6ae129acb416f Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6537 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-09-11flash/stm32l4x: introduce is_max_flash_size and use itTarek BOCHKATI1-9/+8
Change-Id: Idb421b9cf737d222baf4dd890032f69dec7a366e Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6536 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-09-11flash/stm32l4x: fix segmentation fault with HLA adapters and STM32WLx devicesTarek BOCHKATI1-2/+8
CPU2 (Cortex-M0+) is supported only with non-hla adapters because it is on AP1. Using HLA adapters armv7m.debug_ap is null, and checking ap_num triggers a segfault. Change-Id: I501f5b69e629aa8d2836b5194063d74d5bfddb12 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Fixes: https://github.com/STMicroelectronics/OpenOCD/issues/6 Reviewed-on: https://review.openocd.org/c/openocd/+/6535 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-09-04flash/nor/tcl: 'flash list' command: add the flash bank targetTarek BOCHKATI1-0/+2
add the target assigned to the flash bank at creation this is useful in daisy chains, to filter out the target banks. Change-Id: Ic39e44914e34bb62991783762e5a65ef8871e82f Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6426 Tested-by: jenkins Reviewed-by: zapb <dev@zapb.de> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-09-04flash/nor/tcl: fix the flash name returned by 'flash list' commandTarek BOCHKATI1-0/+2
The 'flash list' command returns the driver name as flash name which seems to be incorrect, the proposal is: - to fix this by returning the flash name - and add a new item 'driver' in the returned list example: before the change > flash list {name stm32l4x base 134217728 size 0 bus_width 0 chip_width 0} {name stm32l4x base 201326592 size 0 bus_width 0 chip_width 0} {name stm32l4x base 200933376 size 0 bus_width 0 chip_width 0} after the change > flash list {name stm32l5x.flash_ns driver stm32l4x ...} {name stm32l5x.flash_alias_s driver stm32l4x ...} {name stm32l5x.otp driver stm32l4x ...} Change-Id: I6d307b73c457549981a93c260be344378719af82 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6425 Reviewed-by: zapb <dev@zapb.de> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2021-09-02flash/stm32l4x: avoid using magic numbers for device idsTarek BOCHKATI2-109/+133
Change-Id: I54c41f31c16b91904e8cbca823b90caa3807826d Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6437 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-09-02flash/stm32l4x: add support of STM32WB1xTarek BOCHKATI1-5/+25
STM32WB1x devices has a single flash bank up to 320 KB (page 2KB) note: STM32WB5x/WB3x are single banks as well but do have 4KB as page size. note: remove the assert that checks if max_mages is power of two, because STM32WB1x flash size is not a power of 2 Change-Id: Ib514cf989ecb819d25d1c4a65d641d0a1a3d9f18 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6129 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-09-02flash/stm32l4x: add support of STM32G05/G06xTarek BOCHKATI1-0/+17
this device has single bank flash architecture up to 64KB (page 2KB) reference: RM0444 rev 5 Change-Id: Ia213c01accb950fcbb7519e08057dae11b4443dd Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6128 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-09-02flash/stm32l4x: switch to to c loader instead of assembly loaderTarek BOCHKATI2-36/+54
switching to C loader instead of the assembly version will enhance readability will reduce the maintenance effort. besides the switch to C loader, we added a new parameters to the loader like flash_word_size and flash_sr_bsy_mask in order to support properly STM32U5x and STM32G0Bx/G0Cx in dual-bank mode. Change-Id: I24cafc2ba637a065593a0506eae787b21080a0ba Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6109 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-09-02flash/nor: add support for Nuvoton NPCX series flashWealian Liao3-0/+527
Added NPCX flash driver to support the Nuvoton NPCX series microcontrollers. Add config file for NPCX series. Change-Id: Ia10b019a3521f59ad1e10ccdc56827ba30c3eac8 Signed-off-by: Wealian Liao <WHLIAO@nuvoton.com> Signed-off-by: Mulin Chao <mlchao@nuvoton.com> Reviewed-on: https://review.openocd.org/c/openocd/+/5950 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-08-30flash/stm32l4x: free write_algorithm work area if no space left for the bufferTarek BOCHKATI1-0/+1
If the remaining memory for the buffer is less than 256 bytes, the memory allocated for the write algorithm in the target is not freed. Fixes: ba131f30a079 (Flash driver for STM32G0xx and STM32G4xx) Change-Id: Ic649f6c39799d76725b0c69ff3a009a3f510e17f Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6486 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-08-30flash/stm32l4x: add support of STM32U57x/U58xTarek BOCHKATI1-18/+68
this device flash registers are quite similar to STM32L5 with this changes : - flash size is up to 2MB - 2MB variants are always dual bank - 1MB and 512KB variants could be dual bank (contiguous addressing) depending on DUALBANK bit(21) - flash data width is 16 bytes (quad-word) Change-Id: Id13c552270ce1071479ad418526e8a39ebe83cb1 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6108 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-08-26flash/stm32l4x: add support of STM32WL5x dual coreTarek BOCHKATI2-12/+76
according the RM0453, the second core have a different Flash CR and SR registers for flash operations (called C2CR and C2SR). so we need to a different flash_regs than older L4 devices. @see stm32wl_cpu2_flash_regs the C2CR register don't contain LOCK and OPTLOCK bits, and this explain the addition of new register index called STM32_FLASH_CR_WLK_INDEX to look-up the CR with lock, to be used in locking/unlocking the flash. note: DBGMCU_IDCODE cannot be read using CPU1 (Cortex-M0+) at AP1, to solve this read the UID64 (IEEE 64-bit unique device ID register) Change-Id: Ifb6e291bf97f814f0b9987b2c40f3037959f7af4 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6050 Tested-by: jenkins Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-08-26flash/stm32l4x: prevent undefined behavior warnings caused by signed integer ↵Sebastiaan de Schaetzen1-23/+33
operations When running OpenOCD with -fsanitize=undefined, a warning is emitted for an bit-shifting operation whose result cannot be stored in a signed integer. This is because (1 << 31) overflows a signed integer, which is undefined behavior. By making each of the bit masks act on an unsigned number, the warning is avoided. Whether this warning emitted by UBSan would ever manifest into a real error is debatable, but fixing this does make UBSan happy. Change-Id: I0455a26b234cb4f5e239a6ba90023d28380e9464 Signed-off-by: Sebastiaan de Schaetzen <sebastiaan.de.schaetzen@gmail.com> Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6429 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Oleksij Rempel <linux@rempel-privat.de> Tested-by: jenkins
2021-08-26flash/stm32l4x: add support of STM32G0Bx/G0Cx devicesTarek BOCHKATI2-5/+53
this device has a dual bank flash architecture up to 512 KB (page 2KB) reference: RM0444 Rev 5 notes: - 128k variant is always single bank - 256k variant flash is contiguous (no gap) in dual bank mode - BKER is bit 13 vs bit 11 for other devices > added cr_bker_mask in stm32l4_flash_bank struct - BSY2 for bank 2 operations > added sr_bsy_mask in stm32l4_flash_bank struct > proposed optimization: always wait for (BSY1 | BSY2) with STM32G0Bx/G0Cx devices only (for L4+ devices BSY2=PEMPTY) TODO: update flashloader to use the proper BSY bits temporarily don't use the loader in dual bank mode Change-Id: I54b0c93b494e7209da818791d15edd8cd42c2732 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6036 Reviewed-by: Oleksij Rempel <linux@rempel-privat.de> Tested-by: jenkins
2021-08-26flash/stm32l4x: remove stm32l4_part_info.default_flash_regsTarek BOCHKATI2-27/+19
This struct element is replaced by the usage of F_HAS_L5_FLASH_REGS flag: since over this driver stm32l4_flash_regs is the default register layout, and the only exception is STM32L5 family, so it's simpler to manage it using a flag. Note: the same flag will be used with STM32U5 devices, as they have the same registers layout, which explains the move of stm32l5_s_flash_regs before the switch(device_id) in order to not re-write this for STM32U5. Change-Id: I3b67a6f558d9350f609a22524012b6fceb7de7c2 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6435 Reviewed-by: Oleksij Rempel <linux@rempel-privat.de> Tested-by: jenkins
2021-08-26flash/stm32l4x: introduce flash programming without loaderTarek BOCHKATI1-7/+88
this capability permits to program the flash if we cannot reserve a workarea. the introduction the command 'stm32l4x flashloader <bank_id> [enable|disable]' helps to automatically skip using the flashloader if needed. Change-Id: Id29213c85ee5c7c487cfee21554f5a7ea50db6c9 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6273 Reviewed-by: Oleksij Rempel <linux@rempel-privat.de> Tested-by: jenkins
2021-08-26flash/stm32l4x: STM32L5 support programming when TZEN=1 and RDP=0x55Tarek BOCHKATI1-0/+7
when RDP level is 0.5 the provided work-area should reside in non-secure RAM to ensure that: - add a hint in the driver level - reduce the usage of secure RAM only when TZEN=1 and RDP is not 0.5 (check the target configuration file) Change-Id: Idbf2325e609b84ef8480eefdb49a176fdf7e07c7 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6035 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Oleksij Rempel <linux@rempel-privat.de> Tested-by: jenkins
2021-08-26flash/stm32l4x: STM32L5 support programming when TZEN=1 and RDP=0xAATarek BOCHKATI2-6/+143
STM32L5 flash memory is aliased to 0x0C000000, this address mapping is used for secure applications. (0x08000000 for non-secure) this change allows the programming of secure and non-secure flash when trustzone is enabled and RDP level is 0 Change-Id: I89d1f1b5d493cf01a142ca4dbfef5a3731cab96e Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/5936 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-08-26flash/stm32l4x: introduce auto-probe when OPTR is changedTarek BOCHKATI1-17/+25
auto re-probing is ensured by having optr cache set in the last probe operation. this will help to detect if flash options have been modified by the running application or by the user using direct register access. Change-Id: I05cd7ab9e83a7fc26ac6cff175b3c11b0efa2eb5 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/5935 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Oleksij Rempel <linux@rempel-privat.de> Tested-by: jenkins
2021-08-26flash/stm32l4x: introduce 'stm32l4x trustzone [enable|disable]' commandTarek BOCHKATI1-15/+108
this command will help to enable/disable or display the TrustZone security, using the TZEN option bit. Note: This command works only with devices with TrustZone, eg. STM32L5. Note: This command will perform an OBL_Launch after modifying the TZEN. Change-Id: I4aef15bf57d09c1658d37858143d23b1d43de1f0 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/5542 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Oleksij Rempel <linux@rempel-privat.de>
2021-08-26flash/stm32l4x: do not report bank mode before probing [FIX]Tarek BOCHKATI1-3/+2
in line 1391, get_stm32l4_bank_type_str(bank) will always output the same value "Flash single" since the variable stm32l4_info->dual_bank_mode is false by default, stm32l4_info->dual_bank_mode will be set correctly afterward in the switch case at line 1467 thus the need to remove the usage of get_stm32l4_bank_type_str(bank) before stm32l4_info->dual_bank_mode initialization. Fixes: 64c2e03b23d9 ("flash/nor: improved API of flash_driver.info & fixed buffer overruns") Change-Id: Ia8dc7e144e0ded6143682eb514c247f27859ff81 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6411 Reviewed-by: Oleksij Rempel <linux@rempel-privat.de> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2021-08-22flash/atsame5: use COMMAND_PARSE_NUMBER in command handlersTarek BOCHKATI1-4/+7
the usage of COMMAND_PARSE_NUMBER is safer in COMMAND_HANDLERs since it provides better error checking than strto** functions. Change-Id: Ia7fe9c4017108616f21676f115f151ac62924205 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6423 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2021-08-22flash/kinetis: use COMMAND_PARSE_NUMBER in command handlersTarek BOCHKATI1-7/+9
the usage of COMMAND_PARSE_NUMBER is safer in COMMAND_HANDLERs since it provides better error checking than strto** functions. Change-Id: I972da1a75ba7c41c1b714c2429289c3d24594235 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6422 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2021-08-22flash/xmc4xxx: use COMMAND_PARSE_NUMBER in command handlersTarek BOCHKATI1-2/+2
the usage of COMMAND_PARSE_NUMBER is safer in COMMAND_HANDLERs since it provides better error checking than strto** functions. Change-Id: Ibfe95ce73f147f467de8de23e9573ef0179aed96 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6421 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Tested-by: jenkins
2021-08-22flash/at91samd: use COMMAND_PARSE_NUMBER in command handlersTarek BOCHKATI1-31/+4
the usage of COMMAND_PARSE_NUMBER is safer in COMMAND_HANDLERs since it provides better error checking than strto** functions. Change-Id: I14061cb48da6bac13f9d2896190136f5784b8c07 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6424 Tested-by: jenkins Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
2021-08-22flash/stm32l4x: use COMMAND_PARSE_NUMBER in command handlersTarek BOCHKATI1-4/+5
the usage of COMMAND_PARSE_NUMBER is safer in COMMAND_HANDLERs since it provides better error checking than strto** functions. Change-Id: I7e113b06b74f2d8d9cc4c0ce1957994a1c49c964 Signed-off-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-on: https://review.openocd.org/c/openocd/+/6419 Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-by: Paul Fertser <fercerpav@gmail.com> Tested-by: jenkins
2021-08-14flash/nor: Do not update 'is_erased'Marc Schink27-175/+35
Remove useless setting of the 'is_erased' flag after a flash modification. Also, remove code that erroneously depends on this flag. Keep the flag for now since it is still used by the erase_check() functionality. See commit 07da3b3913dcb6b65564f4fe67c2f26032f180c0 Change-Id: Ia046905bc9e0cb2572145f19251c3e10c4e2d553 Signed-off-by: Marc Schink <dev@zapb.de> Reviewed-on: http://openocd.zylin.com/6279 Tested-by: jenkins Reviewed-by: Tarek BOCHKATI <tarek.bouchkati@gmail.com> Reviewed-by: Tomas Vanek <vanekt@fbl.cz> Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>