STM32GENERIC, my arduino implementation

Cores are the underlying magic that make the Arduino API possible
User avatar
Pito
Posts: 1499
Joined: Sat Mar 26, 2016 3:26 pm
Location: Rapa Nui

Re: STM32GENERIC, my arduino implementation

Post by Pito » Tue May 09, 2017 7:02 pm

danieleff wrote:I think I found the fix for UART RX on F1, committed.
ok
Pukao Hats Cleaning Services Ltd.

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

Re: STM32GENERIC, my arduino implementation

Post by Pito » Tue May 09, 2017 11:14 pm

While trying to print out an

Code: Select all

uint64_t sum;
I get

Code: Select all

error: call of overloaded 'println(uint64_t&)' is ambiguous
     Serial.println(sum);
                       ^
Pukao Hats Cleaning Services Ltd.

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

Re: STM32GENERIC, my arduino implementation

Post by danieleff » Wed May 10, 2017 5:31 pm

Added Mass Storage to the USB menu. I hope I did not break SerialUSB. (Both do not work at the same time).
Given I don't know what the API should be (it will probably be something like `setupMassStorate(...)` that the user has to implement), here is testing code for unformatted ramdisk, tested only on black 407ve:

Code: Select all

#include "msc/usbd_msc.h"

const uint8_t MSC_Inquirydata[] = {
  /* LUN 0 */
  0x00,
  0x80,
  0x02,
  0x02,
  (STANDARD_INQUIRY_DATA_LEN - 5),
  0x00,
  0x00,
  0x00,
  'S', 'T', 'M', ' ', ' ', ' ', ' ', ' ', /* Manufacturer : 8 bytes */
  'P', 'r', 'o', 'd', 'u', 'c', 't', ' ', /* Product      : 16 Bytes */
  ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ',
  '0', '.', '0' ,'1',                     /* Version      : 4 Bytes */
};

const uint16_t blockSize = 512;
const uint32_t blockCount = 100;

uint8_t ramdisk[blockSize * blockCount] = {0};

namespace Testing {

// See UM1734, 6.2.4
// See usbd_msc.h
USBD_StorageTypeDef USBD_DISK_fops = {
    //Init
    [](uint8_t lun) -> int8_t {
        return USBD_OK;
    },

    //GetCapacity
    [](uint8_t lun, uint32_t *block_num, uint16_t *block_size) -> int8_t {
        *block_num  = blockCount;
        *block_size = blockSize;
        return USBD_OK;
    },

    //IsReady
    [](uint8_t lun) -> int8_t {
        return USBD_OK;
    },

    //IsWriteProtected
    [](uint8_t lun) -> int8_t {
        return USBD_OK;
    },

    //Read
    [](uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len) -> int8_t {
        memcpy(buf, ramdisk + blk_addr * blockSize, blk_len * blockSize);
        return USBD_OK;
    },

    //Write
    [](uint8_t lun, uint8_t *buf, uint32_t blk_addr, uint16_t blk_len) -> int8_t {
        digitalWrite(LED_BUILTIN, !digitalRead(LED_BUILTIN));
        memcpy(ramdisk + blk_addr * blockSize, buf, blk_len * blockSize);
        return USBD_OK;
    },

    //GetMaxLun
    []() -> int8_t {return 0;},

    (int8_t *)MSC_Inquirydata

};

}

void setup() {
    pinMode(LED_BUILTIN, OUTPUT);
}

void loop() {
  
}

If you have problems, try to debug, it is unbelivalby hard to debug USB even on own computer.

Pito: There is no print(uint64_t) (yet) which is why it is giving error.

User avatar
RogerClark
Posts: 6698
Joined: Mon Apr 27, 2015 10:36 am
Location: Melbourne, Australia
Contact:

Re: STM32GENERIC, my arduino implementation

Post by RogerClark » Thu May 11, 2017 2:12 am

stevestrong wrote:I think we desperately need a separate "STM32generic" entry under "Bootloaders and cores",
so that each issue can be discussed in separate thread.
Belated.. I've now done this.

FYI.

I someone PM'ed me, I would have done this before.

I had to unexpected be away from home (overseas) since the end of March, and I've only been back at home for a short while, so I'm now trying to read several long threads, including this one ;-)

Edit.

Daniel has asked me to move all the threads to the new section, so I've done that, apart from this thread (and I may move it if Daniel wants me to)
Last edited by RogerClark on Thu May 11, 2017 7:26 am, edited 1 time in total.

michael_l
Posts: 336
Joined: Mon Aug 24, 2015 6:11 pm

Re: STM32GENERIC, my arduino implementation

Post by michael_l » Thu May 11, 2017 4:58 am

michael_l wrote:
ChrisMicro wrote:
L476RG ah then RAM LENGTH = 128K is wrong also.
@michael
Did you try my STM32F4 Discovery examples the microphone is working a little bit ...
Nice work! I'll have to check that.
Just tried this and I can confirm it works. It's fun ! I have to educate myself a bit more about I2S and PDM. Looks like PDM processing is more complicated than I thought originally.

ChrisMicro
Posts: 276
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: STM32GENERIC, my arduino implementation

Post by ChrisMicro » Thu May 11, 2017 6:50 am

Just tried this and I can confirm it works. It's fun ! I have to educate myself a bit more about I2S and PDM. Looks like PDM processing is more complicated than I thought originally.
Thanks for trying :D
The problem with the PDM-microphone is that I had to clock it by "bit banging" ~2.3Mhz and my somehow poor filter implementation.
I think, it could be improved ...
STM has a closed source library, but I don't want to use closed source libraries.

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

Re: STM32GENERIC, my arduino implementation

Post by Pito » Thu May 11, 2017 4:54 pm

danieleff wrote:Pito: There is no print(uint64_t) (yet) which is why it is giving error.
There is, but we have got problems with long vs long long vs int32_t vs int64_t types in print/println definitions, it seems..
Print.h
The maple does it (and it works):

Code: Select all

size_t Print::printNumber(unsigned long long n, uint8 base) 

Code: Select all

    size_t print(long long, int=DEC);
    size_t print(unsigned long long, int=DEC);
here:

Code: Select all

    size_t print(long, int = DEC);
    size_t print(unsigned long, int = DEC);

Code: Select all

size_t Print::printNumber(unsigned long n, uint8 base) 
Here the long int is 32bit, sure..
I added the long long defs but getting an error

Code: Select all

"C:\Users\pito\MyCode\Arduino\hardware\Arduino_STM32SerBuff\STM32DE\cores\arduino\Print.cpp"  -o  "core\Print.cpp.o"
C:\Users\pito\MyCode\Arduino\hardware\Arduino_STM32SerBuff\STM32DE\cores\arduino\Print.cpp:239:8: error: prototype for 'size_t Print::printNumber(long long unsigned int, uint8_t)' does not match any in class 'Print'
 size_t Print::printNumber(unsigned long long n, uint8_t base)
I do not know where

Code: Select all

error: prototype for 'size_t Print::printNumber(long long unsigned int,
comes from..
Edit: libmaple_types are used in maple, we do not use it Here..
I've added

Code: Select all

typedef unsigned long long uint64_t;
typedef long long int64_t;
in the Print.h but still above error.[/s]
OK FIXED..
Here are the two files Print.h and Print.cpp - with added signed/unsigned print/println of 64bitters:
Print.zip
(3.05 KiB) Downloaded 5 times
Pukao Hats Cleaning Services Ltd.

ChrisMicro
Posts: 276
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: STM32GENERIC, my arduino implementation

Post by ChrisMicro » Fri May 12, 2017 2:13 pm

@Daniel

I just tried to compile the both examples in the Black407VE folder. But it didn't work: the include files are missing :!:

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

Re: STM32GENERIC, my arduino implementation

Post by danieleff » Sat May 13, 2017 4:46 am

ChrisMicro wrote:@Daniel

I just tried to compile the both examples in the Black407VE folder. But it didn't work: the include files are missing :!:
You need to install the libraries that are in the first line in the .ino in comments. (SPIFlash from library manager and SdFat-beta from github)

ChrisMicro
Posts: 276
Joined: Fri Mar 24, 2017 4:51 pm
Location: Germany

Re: STM32GENERIC, my arduino implementation

Post by ChrisMicro » Sat May 13, 2017 5:22 am

SPIFlash from library manager and SdFat-beta from github
The problem is: where to find? Can you provide the links?
The best thing for examples would be if they simply compile and run. Would it make sense to include the libraries in the repository?
If not, it would be very helpful to have a link in the description header of the example.

BTW.: I have added new basic examples for the BLACK407VE

I also tried the analogReadSerial-example from the main Arduino examples. I had to replace A0 by e.g. PA0.
The USB-serial worked fine with 115200 baud but hung with 9600baud.

The Ram-Free Examples shows only 124KB RAM instead of 196KB RAM.

Post Reply