[STM32GENERIC] Latest - issues

Discussions about the STM32generic core
User avatar
Pito
Posts: 1628
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

[STM32GENERIC] Latest - issues

Post by Pito » Thu Jun 22, 2017 6:54 pm

I've updated my local repo copy as there came to a lot of developments in a few last days :)
I am currently messing with the BLUE 103ZE variant (see updated BLUE Boards variants in another thread) trying to build the SDCopy demo with F103ZE and SPI/Sdfat. So far I get

Code: Select all

In file included from C:/Users/pito/MyCode/Arduino/hardware/Arduino_STM32SerBuff/STM32DE1/system/STM32F1/CMSIS_Inc/stm32f1xx.h:151:0,
                 from C:/Users/pito/MyCode/Arduino/hardware/Arduino_STM32SerBuff/STM32DE1/cores/arduino/stm32/stm32_def.h:10,
                 from C:\Users\pito\MyCode\Arduino\hardware\Arduino_STM32SerBuff\STM32DE1\libraries\stm32_dma\src\stm32_dma.c:23:
C:/Users/pito/MyCode/Arduino/hardware/Arduino_STM32SerBuff/STM32DE1/system/STM32F1/CMSIS_Inc/stm32f103xe.h:12157:39: error: redefinition of 'DMA2_Channel4_5_IRQHandler'
 #define DMA2_Channel4_IRQHandler      DMA2_Channel4_5_IRQHandler
                                       ^
C:\Users\pito\MyCode\Arduino\hardware\Arduino_STM32SerBuff\STM32DE1\libraries\stm32_dma\src\stm32_dma.c:268:13: note: in expansion of macro 'DMA2_Channel4_IRQHandler'
 extern void DMA2_Channel4_IRQHandler() {
             ^
C:\Users\pito\MyCode\Arduino\hardware\Arduino_STM32SerBuff\STM32DE1\libraries\stm32_dma\src\stm32_dma.c:262:13: note: previous definition of 'DMA2_Channel4_5_IRQHandler' was here
 extern void DMA2_Channel4_5_IRQHandler() {
             ^
Pukao Hats Cleaning Services Ltd.

danieleff
Posts: 336
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: [STM32GENERIC] Latest - issues

Post by danieleff » Fri Jun 23, 2017 4:37 am

There is a also a pull request for those boards, and has a fix for this. Until then, just comment it out.

User avatar
Pito
Posts: 1628
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: [STM32GENERIC] Latest - issues

Post by Pito » Fri Jun 23, 2017 11:12 am

Thanks. I commented the DMA out. Got then error with missing

Code: Select all

#define __HAL_AFIO_REMAP_SPI3_DISABLE() CLEAR_BIT(AFIO->MAPR, AFIO_MAPR_SPI3_REMAP)
and added it manually.
stm32f1xx_hal_gpio_ex.h l.146

Code: Select all

/**
  * @brief Disable the remapping of SPI1 alternate function NSS, SCK, MISO and MOSI.
  * @note  DISABLE: No remap (NSS/PA4,  SCK/PA5, MISO/PA6, MOSI/PA7)
  * @retval None
  */
#define __HAL_AFIO_REMAP_SPI1_DISABLE() CLEAR_BIT(AFIO->MAPR, AFIO_MAPR_SPI1_REMAP)

#define __HAL_AFIO_REMAP_SPI3_DISABLE() CLEAR_BIT(AFIO->MAPR, AFIO_MAPR_SPI3_REMAP)

stm32f103xe.h l. 2482

Code: Select all

#define AFIO_MAPR_SPI3_REMAP_Pos             (28U)                              
#define AFIO_MAPR_SPI3_REMAP_Msk             (0x1U << AFIO_MAPR_SPI3_REMAP_Pos) /*! bit 28 */
#define AFIO_MAPR_SPI3_REMAP                 AFIO_MAPR_SPI3_REMAP_Msk          /*!< SPI3 remapping */
I got then errors with SdSpiSTM32F1.cpp so I replaced it with my version from an older SPI DMA topic http://www.stm32duino.com/viewtopic.php ... 038#p27339 (with defined __STM32F1__). Set SPI at PA5-7 in my variant and Sdcard's chipselect to PC4 (SPI/SdFat works on this board with libmaple).
The SDCopy SPI:

Code: Select all

..
#include "SPI.h"
#include "SdFat.h"
#include "CRC32/CRC32.h"

SdFat sd;
SdFile myFileIn;
SdFile myFileOut;
CRC32 crc;

// SD chip select pin
const uint8_t chipSelect = PC4; //PB6 Black407; PC4 BlueZE, PB12 MM

#define BUFSIZE 32*1024

// Serial output stream
ArduinoOutStream cout(Serial);

void setup() {
    Serial.begin(115200);
    delay(3000);
    cout << F("\nUse a freshly formatted SD for best performance..\n");
    if (!sd.begin(chipSelect, SD_SCK_MHZ(10))) {
      sd.initErrorHalt();
    }
}
..
Now it compiles, but cannot init the Sdcard.

Code: Select all

Can't access SD card. Do not reformat.
SD errorCode: 0X60,0X1
Am I doing something wrong with the latest? How to compile SDCopy bench w/ SPI and SdFat - maybe I mess with wrong files here, or I miss something? Using SPI/stm32_dma/SdFat from latest.
Could you try to run the SDcopy wih SPI on an F103 with your setup there, plz?
Pukao Hats Cleaning Services Ltd.

stevestrong
Posts: 1829
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: [STM32GENERIC] Latest - issues

Post by stevestrong » Fri Jun 23, 2017 4:24 pm

Pito wrote:
Fri Jun 23, 2017 11:12 am
Could you try to run the SDcopy wih SPI on an F103 with your setup there, plz?
Libmaple core: BP, CPU@72MHz, SPI_1@36MHz, flash wait states = 1, BUFSIZE = 14kB (more does not fit into RAM):

Code: Select all

#################################################
Opening the read file..
Opening the write file..
Reading and Writing..
File size = 102400000 bytes.
*************************************************
Done in 76582 msecs
*************************************************
Running CRC calculations...
*************************************************
*************************************************
File in CRC:  22BCDBEC
File out CRC: 22BCDBEC
*************************************************
Done in 253858 msecs
EDIT
I have added a progress bar feature + show file size + distinguish between F1 (SPI) and F4 (SDIO) by #ifdef.
Attachments
copytest.ino
(4.1 KiB) Downloaded 16 times
Last edited by stevestrong on Fri Jun 23, 2017 7:42 pm, edited 1 time in total.

User avatar
Pito
Posts: 1628
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: [STM32GENERIC] Latest - issues

Post by Pito » Fri Jun 23, 2017 5:31 pm

But under Generic?
Pukao Hats Cleaning Services Ltd.

User avatar
Pito
Posts: 1628
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: [STM32GENERIC] Latest - issues

Post by Pito » Sat Jun 24, 2017 9:32 pm

Updated my local repo again with today's latest changes..
After an hour coping with errors I finally added to compile options the new ARCH flag (Blue F103ZET, 72/18MHz, SPI, SdFatEX, Buf=32kB, 2MB file)

Code: Select all

-DSTM32F1 -D__STM32F1__ -DARDUINO_ARCH_STM32
and got:

Code: Select all

Use a freshly formatted SD for best performance..
*************************************************
Opening the read file..
Opening the write file..
Reading and Writing..
*************************************************
Done in 2305 msecs
*************************************************
Running CRC calculations...
File in CRC:  7D33183E
File out CRC: 7D33183E
*************************************************
Done in 5453 msecs
Not sure I do understand the SPI/SdFat settings now as there are too many changes with it.. :)
Pukao Hats Cleaning Services Ltd.

stevestrong
Posts: 1829
Joined: Mon Oct 19, 2015 12:06 am
Location: Munich, Germany

Re: [STM32GENERIC] Latest - issues

Post by stevestrong » Sun Jun 25, 2017 9:11 am

And how is performing with a 102400kB file?

User avatar
Pito
Posts: 1628
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: [STM32GENERIC] Latest - issues

Post by Pito » Sun Jun 25, 2017 11:35 am

stevestrong wrote:
Sun Jun 25, 2017 9:11 am
And how is performing with a 102400kB file?
F103ZET, 72MHz, 18MHz SPI, flash ws=2, Buffersize = 32kB, SdFatEX, 104.4MB file, Samsung EVO CL10

Code: Select all

Use a freshly formatted SD for best performance..
*************************************************
Opening the read file..
Opening the write file..
Reading and Writing..
*************************************************
Done in 135574 msecs
*************************************************
Running CRC calculations...
File in CRC:  22483A52
File out CRC: 22483A52
*************************************************
Done in 266093 msecs
With 36MHz SPI I am getting following error:

Code: Select all

Use a freshly formatted SD for best performance..
Can't access SD card. Do not reformat.
SD errorCode: 0X31,0X7F

Use a freshly formatted SD for best performance..
Can't access SD card. Do not reformat.
SD errorCode: 0X31,0X7F
The same error with Sandisk Ultra CL10 at 36MHz (at 18MHz 119sec/266sec).

Interestingly this setup worked few weeks back with SPI DMA under Victor's generic @44MHz SPI fine with Samsung and 36MHz with Sandisk..

Note: with latest changes in the Generic repo I am not sure whether the dma is on/off or not..
Last edited by Pito on Sun Jun 25, 2017 2:23 pm, edited 2 times in total.
Pukao Hats Cleaning Services Ltd.

User avatar
Pito
Posts: 1628
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: [STM32GENERIC] Latest - issues

Post by Pito » Sun Jun 25, 2017 12:16 pm

This is the Sandisk at 18MHz SPI (36MHz SPI with the error as above) in the bench:

Code: Select all

File size 5 MB
Buffer size 512 bytes
Starting write test, please wait.

write speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
1946.16,24128,254,261
1964.51,11305,254,258
1926.66,36394,254,263

Starting read test, please wait.

read speed and latency
speed,max,min,avg
KB/Sec,usec,usec,usec
1984.79,1155,255,256
1984.79,1154,255,256
1984.79,1155,255,256

Done
The same with Samsung.. Thus the 36MHz SPI ia a nogo today :)
Pukao Hats Cleaning Services Ltd.

danieleff
Posts: 336
Joined: Thu Sep 01, 2016 8:52 pm
Location: Hungary
Contact:

Re: [STM32GENERIC] Latest - issues

Post by danieleff » Sun Jun 25, 2017 2:36 pm

The only thing changed lately that can affect SPI high speed is `smt32_gpio_af_F1.c` changed from
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
to
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_MEDIUM;

Post Reply