RTduino / RTduino

Arduino Ecosystem Compatibility Layer for RT-Thread | RT-Thread的Arduino生态兼容层
https://docs.rtduino.com
Other
95 stars 21 forks source link

pins_arduino.h missing RA6M3 HMI-Board #78

Closed DansDesigns closed 8 months ago

DansDesigns commented 9 months ago

RT-Thread reports rtduino is missing pins_arduino.h for the RA6M3 HMI-Board.

Is there a fix for this?

In file included from C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Print.h:39,
                 from C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Stream.h:38,
                 from C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\libraries\buildin\Wire/Wire.h:40,
                 from ../src/hal_entry.c:14:
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Printable.h:37:1: error: unknown type name 'class'
   37 | class Print;
      | ^~~~~
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Printable.h:45:1: error: unknown type name 'class'
   45 | class Printable
      | ^~~~~
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Printable.h:46:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   46 | {
      | ^
In file included from C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Stream.h:38,
                 from C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\libraries\buildin\Wire/Wire.h:40,
                 from ../src/hal_entry.c:14:
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Print.h:46:1: error: unknown type name 'class'
   46 | class Print
      | ^~~~~
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Print.h:47:1: error: expected '=', ',', ';', 'asm' or '__attribute__' before '{' token
   47 | {
      | ^
In file included from C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\libraries\buildin\Wire/Wire.h:40,
                 from ../src/hal_entry.c:14:
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Stream.h:61:1: error: unknown type name 'class'
   61 | class Stream : public Print
      | ^~~~~
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Stream.h:61:14: error: expected '=', ',', ';', 'asm' or '__attribute__' before ':' token
   61 | class Stream : public Print
      |              ^
In file included from C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\libraries\buildin\Wire/Wire.h:41,
                 from ../src/hal_entry.c:14:
C:\RT-ThreadStudio\workspace\hmi-board-factory\packages\RTduino-latest\core/Arduino.h:57:10: fatal error: pins_arduino.h: No such file or directory
   57 | #include "pins_arduino.h"
      |          ^~~~~~~~~~~~~~~~
compilation terminated.
make: *** [src/subdir.mk:18: src/hal_entry.o] Error 1
make: *** Waiting for unfinished jobs....
"make -j4 all" terminated with exit code 2. Build might be incomplete.

03:21:58 Build Failed. 10 errors, 0 warnings. (took 7s.964ms)
DansDesigns commented 9 months ago

I couldn't find a solution to the pins_arduino issue so I modified the example ones for the STM32, I am not sure if they work yet as I still have issues with 'class' not being recognized in SPI.h, Wire.h, Print.h, Printable.h and Stream.h...

I have attached them to this post so maybe someone else can verify if they work? pins_arduino.zip

DansDesigns commented 9 months ago

Somehow the 'class' error has fixed itself but now the modified pins_arduino.c is giving the following error: ../packages/RTduino-latest/core/pins_arduino.c:25:10: error: initializer element is not constant this is referencing the first line where D0 is defined but the error applies to all lines.. I did not change the structure of the file just the pins.. here is the contents of the modified pins_arduino.c:

/*
 * Copyright (c) 2006-2022, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2022-09-20     liYony       first version
 * 19/10/2023     Daniel Miles  updated for RA6M3
 *
 */

#include <Arduino.h>
#include "pins_arduino.h"

/*
 * {Arduino Pin, RT-Thread Pin [, Device Name, Channel]}
 * [] means optional
 * Digital pins must NOT give the device name and channel.
 * Analog pins MUST give the device name and channel(ADC, PWM or DAC).
 * Arduino Pin must keep in sequence.
 */
const pin_map_t pin_map_table[]=
{
    {D0, GET_PIN(P206), "uart1"},      /* Serial-Rx */
    {D1, GET_PIN(P205), "uart1"},       /* Serial-Tx */
    {D2, GET_PIN(P008)},
    {D3, GET_PIN(P506)},
    {D4, GET_PIN(P603), "pwm1", 1},      /* PWM */
    {D5, GET_PIN(P604), "pwm1", 2},     /* PWM */
    {D6, GET_PIN(P605), "pwm1", 3},     /* PWM */
    {D7, GET_PIN(P208)},
    {D8, GET_PIN(P207)},                /* LED_BUILTIN */
    {D9, GET_PIN(P009), "adc1", 5},      /* ADC */
    {D10, GET_PIN(P712), "pwm1", 4},     /* PWM */
    {D11, GET_PIN(P512), "spi1"},       /* SPI-MOSI */
    {D12, GET_PIN(P511), "spi1"},       /* SPI-MISO */
    {D13, GET_PIN(P204),  "spi1"},       /* SPI-SCK */
    {D14, GET_PIN(P203), "i2c1"},        /* I2C-SDA (Wire) */
    {D15, GET_PIN(P202), "i2c1"},        /* I2C-SCL (Wire) */
    {D16, GET_PIN(P209), "led_user1"},       /* user LED 1 */
    {D17, GET_PIN(P210), "led_user2"},       /* user LED 2 */
    {D18, GET_PIN(P005), "btn_user0"},       /* user button 0 */
    {D19, GET_PIN(P006), "btn_user1"},       /* user button 1 */
    {D20, GET_PIN(P007), "btn_user2"},       /* user button 2 */
    {A0, GET_PIN(P00), "adc1", 1},      /* ADC */
    {A1, GET_PIN(P001), "adc1", 2},      /* ADC */
    {A2, GET_PIN(P002), "adc1", 3},      /* ADC */
    {A3, GET_PIN(P003), "adc1", 4},      /* ADC */
    {A4, GET_PIN(P508)},
    {A5, GET_PIN(P014), "adc1", 6},      /* ADC */
    //{A6, RT_NULL, "adc1", RT_ADC_INTERN_CH_VREF},   /* ADC, On-Chip: internal reference voltage */
};
DansDesigns commented 9 months ago

Any help with this would be greatly appreciated.. This was part of my entry into the RT-Thread Embedded GUI Contest 2023 but I am unable to complete the project due to this error.

kurisaW commented 9 months ago

@DansDesigns Hello, currently HMI-Board supports RTduino, you can go to RT-Thread cloning project.Please go to this link to view the RTduino usage documentation and close this issue

DansDesigns commented 9 months ago

Hi kurisaW,

Thank you for your response. I followed the link you provided but all it gave me was this error:

404 - page not found
The 
master

 branch of 
rt-thread

 does not contain the path 
bsp/renesas/ra6m3-hmi-board/board/rtduino/arduino_pinout/README.md.

The board folder does not contain a folder called rtduino??

I have been able to translate the Chinese Readme into English but it does not have any useful information about how to troubleshoot RTduino or the issue present in this and issue#79..

EDIT: I started again and made a new RT-Thread Project, using the hmi-board-factory example. enabled RTduino and the SPI and WIRE libraries, changed rw007 and lvgl version to "latest", saved the changes in RT-Thread Settings, rebuilt the project, updated packages, click build and the same errors appear..

kurisaW commented 9 months ago

@DansDesigns Since yesterday's pr has not been merged, now you can check the specific use process through the above link, and please feedback to us if you have any questions in the future.

mysterywolf commented 9 months ago

Hi, sorry for the late respond. I am too busy, I have merged the PR, please check again.

DansDesigns commented 8 months ago

Hi @mysterywolf & @kurisaW, thank you for your replies,

I checked that link again and the readme is now present.. however when starting a new project (or updating an existing one) the errors still persist, should i manually put the "pins_arduino" files into the correct folders??

Please see attached image for more info

Also i noticed that the I2C1 SCL and SDA are not referenced in the pins_arduino.c however they are already defined in rtconfig.. my hardware is already made to match those pins for I2C1.. is I2C1 usable in rtduino?

rt-thread_rtduino_error

EDIT: So i manually copied the contents of pins_arduino.c and pins_arduino.h from the readme linked above and the errors are reduced to just one:

arm-none-eabi-gcc "../board/ra6m3_it.c"
linking...
c:/rt-threadstudio/repo/extract/toolchain_support_packages/arm/gnu_tools_for_arm_embedded_processors/10.2.1/bin/../lib/gcc/arm-none-eabi/10.2.1/../../../../arm-none-eabi/bin/ld.exe: cannot open linker script file memory_regions.ld: No such file or directory
collect2.exe: error: ld returned 1 exit status
make: *** [makefile:188: rtthread.elf] Error 1
"make -j4 all" terminated with exit code 2. Build might be incomplete.

I have run updates on all the required bits in the SDK Manager, I have even completely removed and reinstalled RT-Thread Studio but the error still remains. In SDK Manager i have the latest version of 10.2.1 of the gnu_tools_for_arm_embedded_processors??

kurisaW commented 8 months ago

@DansDesigns In fact, you shouldn't select RTduino in the package, please clear all Rtduino-related configuration, and follow my next steps to enable RTduino:

  1. Open RT-Thread studio settings
  2. Select 'Hardware' from the Status bar 3.Onboard Peripheral Drivers -->Compatible with Arduino Ecosystem (RTduino) (Enable this option)
  3. Press ctrl+s to save the configuration, download the software package, and compile it

image

image

After the program is burned, open the msh terminal and use the 'list device' command, you should see that the following devices are registered and the RTduino thread's log information is automatically printed when activated

image

DansDesigns commented 8 months ago

hi @kurisaW,

Thank you for the great tutorial, It would seem we are using something different as I have no option for "Onboard Peripheral Drivers"... rt-thread_rtduino-hardware-issue

to be honest I am at the end of my rope. I have been struggling with this for over 2 months! I am going to throw the board away as it is SO stressful getting a simple arduino layer working.. The difficulty i have had with this board has really put me off working on my own projects and I feel like never touching rtthread again..

Thank you for all your help, I hope other are able to get this working. kind regards

kurisaW commented 8 months ago

@DansDesigns A few points need to be made clear to you again:

  1. Please download the latest source code of the RT-Thread repository:
  2. It is recommended that you use RT-Thread's env tool:

Env to use at the same time please refer to the document center tutorial:

Here are some common commands for env:

scons-j8 // 8 core compiled source code
scons-c // Clear the build
scons --menuconfig // Opens the menu configuration interface, equivalent to settings in Studio
pkgs --update // Update and download the software package
  1. Directly go to the HMI-Board bsp directory for compilation, or import it to studio

Additional note: For developers, the use of RT-Thread is relatively easy to get started, but the new white need to learn more and draw on the development process of RT-Thread, once you are familiar with the development, I believe you will understand the convenience of RT-Thread


To answer your question above: "I have no option for "Onboard Peripheral Drivers"

This is because the adaptation PR of RTduino was merged yesterday, and you need to synchronize the master branch with git locally. You can refer to my above instructions again for the use configuration after that. If you have any other questions, please contact me!

mysterywolf commented 8 months ago

please try use env+vscode