reymor / stm32f429-tflite-micro-mnist

Handwritten number recognition with STMF429 TFlite micro mnist
MIT License
22 stars 7 forks source link

How to run this? #1

Closed rmknan closed 5 months ago

rmknan commented 5 months ago

Could you tell me how do I upload this to the MCU? The STM IDE does not recognize the project and am unable to build.

Thanks for the help.

reymor commented 5 months ago

Hello @rmknan

I did not add any build system. Here, you have many ways of doing so. I will say two of them:

If you need any assistance, I could add the build system.

rmknan commented 5 months ago

I followed through the 1st one and made a C++ project. I can build now but I have been facing issues while trying to include the various headers that one has to. I tried including the basic ones and the ones with TF but I face errors.

If you could answer both it would be great!

Thanks!

reymor commented 5 months ago

Hello again @rmknan

Ok,

Right click over the project and click properties. There go to C/C++ Build > Settings

There in Tool settings click in MCU GCC Compiler and in Include paths and the following:

In MCU G++ Compiler in Include paths

You shall select C++14.

In addition, In Preprocessor you also need to define STM32F429I_DISC1, STM32F429xx, STM32, STM32F429ZITx, STM32F4 in both GCC and G++ Compiler

In my case, it is just that I don't like the idea of the STM32CubeIDE, it is more a preference. So, in my case, I use STM32CubeIDE for debug and develop of the app and I was expected to introduce an independent build system, but I just change to other project/ideas jeje

But If you face any major issues doing this, I could add the build system with stm32cube idea which I think that I could not spent to much time on doing so

rmknan commented 5 months ago

I did include the files but I face these errors. These were the errors that i faced before too. These are some of them but all of them are centered around arm_nnfunction or CMSIS_NN. I tried including these directories in the Include paths but nothing changes.

fatal error: arm_nnfunctions.h: No such file or directory fatal error: arm_nnsupportfunctions.h: No such file or directory fatal error: kiss_fft.h: No such file or directory make: *** [tensorflow-lite/third_party/cmsis_nn/Source/PoolingFunctions/subdir.mk:34: tensorflow-lite/third_party/cmsis_nn/Source/PoolingFunctions/arm_avgpool_get_buffer_sizes_s16.o] Error 1

reymor commented 5 months ago

Hello @rmknan

Which FW version are you using?

I just recorded this small video to show you how I did this. This is on ubuntu, but I shall be similar in Windows.

https://drive.google.com/file/d/14G14hAFc-xnRKZxfebsdhDmlFrnan_E-/view?usp=sharing

Best regards,

rmknan commented 5 months ago

Which FW version are you using?

STM32Cube FW_F4 V1.28.0 I am using Ubuntu 22.04 C++14 is selected in the G++ tool settings

Is that what you asked?

I did the same as done in the video but I face the errors mentioned above.

PS - I have not done any TF projects on STM before.. I have Bazel installed but maybe something else is needed?

reymor commented 5 months ago

Yeah, that's what I was asking for. I think that I see what is going on. It was my fault, sorry. I was testing an old version of the project.

You also need to include:

In addition, you shall define:

In both: MCU GCC Compiler and MCU G++ Compiler

PS: This does not have anything to do with Bazel. In general, the workflow working with tensorflow-lite is just getting the source code from here. From there, you could generate the folder structure that you use in your project. For using that project, you will need certain dependencies. However, here I just did that job.

I hope that now you could use the project.

rmknan commented 5 months ago

Great!! It works now. Thank you!! I also had to change the sysmem.cfile. It was using some old terminology.

I would like to learn more about TF in MCUs.. Could you tell me how you started with it?

When I write on the touch panel It seems I have to write it in a mirrored way, Where can I change that?

I think i also need to calibrate my panel, the numbers only appears when I write on the bottom half.

reymor commented 5 months ago

Hi,

Could you please elaborate what you mean with mirrored way?

About tf in mcus. I wrote an small entry about how I got into this small project. Basically, I enrolled into a edx free course. This gave the idea of how this work.

The documentation from Tensorflow is quite good. In addition, in the original repository there are some examples. At the moment that I did this project (sept-2020) there was quite few documentation and few examples. Now, this situation has been improved. There are examples which I think are interesting to grasp some ideas about how it works.

rmknan commented 5 months ago

Could you please elaborate what you mean with mirrored way?

I cannot write normally as you would on paper. The directions are reversed. If I move my pencil up then it draws a line going down.

Thank you for the links I will look into it.

reymor commented 5 months ago

mmm, I'm not really sure, maybe it is realted with the calibration process because I have tested without any problem as you can see in the repo