Hey Guys,
I am gonna be honest, i am a major beginner when it comes to this stuff, I can bumble my way through on most things though.
SO i purchased one of Olimex fantastic ESP32 Dev boards Rev B because i had see a article on Hackaday about CAN support on the ESP32 and i wanted to try it out, i have a project in mind that sends CAN data over bluetooth but thats a liittle ahead of myself.
I have managed to, through following some fantastic tutorials provided by this community get my Windows PC working with the ESP-IDF. I have flashed my ESP a few times, including a websockets example i found on github. However when i have tried to flash the CAN demo that Rudi and Thomas Barth had created i am having a few compiling issues, I read through the forun post about the CAN controller and from my understanding after i downloaded the Demo file, i shouldn't need to ad the DRV folder containing CAN into the include files within ESP-IDF however when i try to compile i am met with this error
$ make
CC //main.o
AR libmain.a
LD CAN_demo.elf
C:/msys32/home/rossf/esp/esp-idf/examples/ESP32_CAN_demo/build/main\libmain.a(main.o):(.literal.task_CAN+0x0): undefined reference to `CAN_cfg'
collect2.exe: error: ld returned 1 exit status
make: *** [C:/msys32/home/rossf/esp/esp-idf/make/project.mk:323: /home/rossf/esp/esp-idf/examples/ESP32_CAN_demo/build/CAN_demo.elf] Error 1
Undefined reference to me seems to suggest that the CAN.cfg file is being pointed to but the file isn't there, Acting on that hunch, i tried moving the files inside the DRV file into the make directory with no luck.
If anybody has some information on where i am going wrong that would be great.
Thanks
Ross
ESP32 CAN demo on Olimex ESP32 REVB compile issue
ESP32 CAN demo on Olimex ESP32 REVB compile issue
- Attachments
-
- Capture.PNG (11.14 KiB) Viewed 11433 times
-
- Capture.PNG (11.14 KiB) Viewed 11433 times
Re: ESP32 CAN demo on Olimex ESP32 REVB compile issue
hi ross
welcome
vid sequenze from begin - start here
from your post i read, you have done in the past successful compile in your environment.
so use your favority eclipse empty project that contains esp-idf and environment setup well.
for a fast test compile setup, download the hello world example from ESP-IDF
and push this in your empty project.
( you can start a simply compile here - but wait )
there are origin and forked repo with changes available
the base is the same, download one,
here in this example
download the CAN driver pack and push the component to your project
you have now the CAN component in your project.
cause the driver pack is created on the GPIO4 and GPIO5 successful
you have to expand the RANGE in the "Kconfig" file under the CAN Component by self
example Olimex use
Rx GPIO35
Tx GPIO 5
save it and run menuconfig on your favority way like you did in the past.
you see now CAN under component config,
setup your node, Rx, Tx, Baud, and if you want use the CONFIG Define example send test frame, you can set here and you have then a possible way in your code to use
you can start now a test compile.
this must compile without problem.
now you can update or rename the hello world file ( *.bak )
and create a new CAN demo file example
if you use the CAN Demo so be sure, there are small changes need
cause the the structure of CAN Demo was that the driver is in the project and not as component,
so this can be the reason why your compile fails.
i will append here in next time an update on the CAN Demo -
so you can in the meantime start with yours
let me know how you get on in this
for next CAN Projects
you can simply copy and paste your test project and you have all on right place,
the component CAN too.
btw - if you want, you can place the component CAN to the ESP-IDF component folder too
so you need not more append the component CAN to your next projects.
like you want to do.
hope this helps for first steps.
best wishes
rudi
welcome
vid sequenze from begin - start here
from your post i read, you have done in the past successful compile in your environment.
so use your favority eclipse empty project that contains esp-idf and environment setup well.
for a fast test compile setup, download the hello world example from ESP-IDF
and push this in your empty project.
( you can start a simply compile here - but wait )
there are origin and forked repo with changes available
the base is the same, download one,
here in this example
download the CAN driver pack and push the component to your project
you have now the CAN component in your project.
cause the driver pack is created on the GPIO4 and GPIO5 successful
you have to expand the RANGE in the "Kconfig" file under the CAN Component by self
example Olimex use
Rx GPIO35
Tx GPIO 5
save it and run menuconfig on your favority way like you did in the past.
you see now CAN under component config,
setup your node, Rx, Tx, Baud, and if you want use the CONFIG Define example send test frame, you can set here and you have then a possible way in your code to use
enbable/disable send test frames
- CONFIG_CAN_TEST_SENDING_ENABLED
- CONFIG_CAN_TEST_SENDING_DISABLED
you can start now a test compile.
this must compile without problem.
now you can update or rename the hello world file ( *.bak )
and create a new CAN demo file example
if you use the CAN Demo so be sure, there are small changes need
cause the the structure of CAN Demo was that the driver is in the project and not as component,
so this can be the reason why your compile fails.
i will append here in next time an update on the CAN Demo -
so you can in the meantime start with yours
let me know how you get on in this
for next CAN Projects
you can simply copy and paste your test project and you have all on right place,
the component CAN too.
btw - if you want, you can place the component CAN to the ESP-IDF component folder too
so you need not more append the component CAN to your next projects.
like you want to do.
hope this helps for first steps.
best wishes
rudi
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
Re: ESP32 CAN demo on Olimex ESP32 REVB compile issue
here we are vid part 2
CAN Demo based on the CAN Driver Pack
Rx = GPIO 35
Tx = GPIO 5
Baud = 125K
Node = 197 ( 0xC5 )
visit github ESP32DE
best wishes
rudi
CAN Demo based on the CAN Driver Pack
Rx = GPIO 35
Tx = GPIO 5
Baud = 125K
Node = 197 ( 0xC5 )
visit github ESP32DE
Code: Select all
/*
* my_olimexikus_CAN.c
*
* Created on: 14.06.2017
* Author: rudi ;-)
*
* Olimex EVB REV B
* with CAN
* CAN Rx = GPIO 35
* CAN Tx = GPIO 5
* Node = 197 ( you can change all in Kconfig )
*
* done ;-)
* ....
* code comes later to olimex github
* after PR visit it here
* https://github.com/OLIMEX/ESP32-EVB/tree/master/SOFTWARE
* have phun
* best wishes
* rudi ;-)
*/
#include "freertos/FreeRTOS.h"
#include "esp_wifi.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_event_loop.h"
#include "nvs_flash.h"
#include "CAN.h"
#include "CAN_config.h"
/* brief : rudi
* content: Set the CAN Speed over Kconfig
* you can use menuconfig for this
* and you can expand like you need
* you can also use your own
* cfg - look in the main/cfg folder
* you have then change by self
*/
#ifndef CONFIG_ESPCAN
#error for this demo you must enable and configure ESPCan in menuconfig
#endif
#ifdef CONFIG_CAN_SPEED_100KBPS
#define CONFIG_SELECTED_CAN_SPEED CAN_SPEED_100KBPS
#endif
#ifdef CONFIG_CAN_SPEED_125KBPS
#define CONFIG_SELECTED_CAN_SPEED CAN_SPEED_125KBPS
#endif
#ifdef CONFIG_CAN_SPEED_250KBPS
#define CONFIG_SELECTED_CAN_SPEED CAN_SPEED_250KBPS
#endif
#ifdef CONFIG_CAN_SPEED_500KBPS
#define CONFIG_SELECTED_CAN_SPEED CAN_SPEED_500KBPS
#endif
#ifdef CONFIG_CAN_SPEED_800KBPS
#define CONFIG_SELECTED_CAN_SPEED CAN_SPEED_800KBPS
#endif
#ifdef CONFIG_CAN_SPEED_1000KBPS
#define CONFIG_SELECTED_CAN_SPEED CAN_SPEED_1000KBPS
#endif
#ifdef CONFIG_CAN_SPEED_USER_KBPS
#define CONFIG_SELECTED_CAN_SPEED CONFIG_CAN_SPEED_USER_KBPS_VAL /* per menuconfig */
#endif
/* brief : rudi
* content: config CAN Speed, Tx, Rx Pins taken from Kconfig
* over menuconfig you can set the cfg
* defines are used in the head of code then
* if you change to user cfg
* you can change here too by your self
* how you need this.
*/
CAN_device_t CAN_cfg = {
.speed = CONFIG_SELECTED_CAN_SPEED, // CAN Node baudrade
.tx_pin_id = CONFIG_ESP_CAN_TXD_PIN_NUM, // CAN TX pin example menuconfig GPIO_NUM_5
.rx_pin_id = CONFIG_ESP_CAN_RXD_PIN_NUM, // CAN RX pin example menuconfig GPIO_NUM_35 ( Olimex )
.rx_queue = NULL, // FreeRTOS queue for RX frames
};
esp_err_t event_handler(void *ctx, system_event_t *event)
{
return ESP_OK;
}
void task_CAN( void *pvParameters ){
(void)pvParameters;
//frame buffer
CAN_frame_t __RX_frame;
//create CAN RX Queue
CAN_cfg.rx_queue = xQueueCreate(10,sizeof(CAN_frame_t));
//start CAN Module
CAN_init();
printf("Can Init done - wait now..\n");
while (1){
//receive next CAN frame from queue
if(xQueueReceive(CAN_cfg.rx_queue,&__RX_frame, 3*portTICK_PERIOD_MS)==pdTRUE){
//do stuff!
// printf("New Frame from 0x%08x, DLC %d, dataL: 0x%08x, dataH: 0x%08x \r\n",__RX_frame.MsgID, __RX_frame.FIR.B.DLC, __RX_frame.data.u32[0],__RX_frame.data.u32[1]);
printf("Frame from : 0x%08x, DLC %d \n", __RX_frame.MsgID, __RX_frame.FIR.B.DLC);
printf("D0: 0x%02x, ", __RX_frame.data.u8[0]);
printf("D1: 0x%02x, ", __RX_frame.data.u8[1]);
printf("D2: 0x%02x, ", __RX_frame.data.u8[2]);
printf("D3: 0x%02x, ", __RX_frame.data.u8[3]);
printf("D4: 0x%02x, ", __RX_frame.data.u8[4]);
printf("D5: 0x%02x, ", __RX_frame.data.u8[5]);
printf("D6: 0x%02x, ", __RX_frame.data.u8[6]);
printf("D7: 0x%02x\n", __RX_frame.data.u8[7]);
printf("==============================================================================\n");
//loop back frame
// CAN_write_frame(&__RX_frame);
}
}
}
void task_CAN_TX(void* pvParameters) {
CAN_frame_t __TX_frame;
uint32_t counter = 0;
__TX_frame.MsgID = CONFIG_ESP_CAN_NODE_ITSELF;
__TX_frame.FIR.B.DLC = 8;
__TX_frame.data.u8[0] = 'E';
__TX_frame.data.u8[1] = 'S';
__TX_frame.data.u8[2] = 'P';
__TX_frame.data.u8[3] = '-';
__TX_frame.data.u8[4] = 'C';
__TX_frame.data.u8[5] = 'A';
__TX_frame.data.u8[6] = 'N';
__TX_frame.data.u8[7] = counter;
while(1) {
__TX_frame.data.u8[7] = counter;
CAN_write_frame(&__TX_frame);
printf("frame send [%3d]\r", counter);
fflush(stdout);
vTaskDelay( 1000 / portTICK_PERIOD_MS); // to see ( printf on receiver side ) what happend..
counter++;
if (counter >= 256) counter = 0;
}
}
void app_main(void)
{
// wait for all print Infos
vTaskDelay( 1000 / portTICK_PERIOD_MS);
// Create CAN receive task
// xTaskCreate(&task_CAN, "CAN", 2048, NULL, 5, NULL);
/*brief: rudi
* if you have "activate ESPCan"
* then the code here runs..
*
*/
#ifdef CONFIG_ESPCAN
printf("********** CAN TESTINGS **********\n");
printf("Olimex EVB Rev B Board \n");
printf("ESPCan configured by this Data:\n");
printf("Node : 0x%03x\n", CONFIG_ESP_CAN_NODE_ITSELF);
printf("CAN RXD PIN NUM: %d\n", CONFIG_ESP_CAN_RXD_PIN_NUM);
printf("CAN TXD PIN NUM: %d\n", CONFIG_ESP_CAN_TXD_PIN_NUM);
printf("CAN SPEED : %d KBit/s\n", CONFIG_SELECTED_CAN_SPEED);
#ifdef CONFIG_CAN_SPEED_USER_KBPS
printf("kBit/s setting was done by User\n");
#endif
//Create CAN receive task
xTaskCreate(&task_CAN, "CAN", 2048, NULL, 5, NULL);
/* check if we have set a test frame to send in Kconfig */
#ifdef CONFIG_CAN_TEST_SENDING_ENABLED
printf("Test Frame sending is enabled\n");
vTaskDelay( 1000 / portTICK_PERIOD_MS);
xTaskCreate(&task_CAN_TX, "task_CAN_TX", 2048, NULL, 5, NULL);
#endif
#endif
}
rudi
- Attachments
-
- controll.jpg (277.08 KiB) Viewed 11382 times
-
- IMG_7500_s.jpg (232.58 KiB) Viewed 11382 times
-
- IMG_7499_s.jpg (54.36 KiB) Viewed 11382 times
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
Re: ESP32 CAN demo on Olimex ESP32 REVB compile issue
Rudi,
Thank you so much for this,
I tried out your demo code and it worked flawlessly. It looks like it is sending out those test frames fine, I am going to bring my board into work tomorrow and test it on our CAN baud tester but by all acounts it looks like i should be able to continue with my project. Thank you, you really went above and beyond what was needed all for a stranger.
Many thanks
Rocketman
Thank you so much for this,
I tried out your demo code and it worked flawlessly. It looks like it is sending out those test frames fine, I am going to bring my board into work tomorrow and test it on our CAN baud tester but by all acounts it looks like i should be able to continue with my project. Thank you, you really went above and beyond what was needed all for a stranger.
Many thanks
Rocketman
- Attachments
-
- Capture.PNG (30.23 KiB) Viewed 11336 times
Re: ESP32 CAN demo on Olimex ESP32 REVB compile issue
Thanks for your kind words 'Rocketman'
Hope you get as far as you can - just write when something goes wrong.
If the problem is for you solved feel free to edit on your first post title to [solved]
btw have read in your post from Websockets..
Then we go on with next steps with ETH PHY - LAN ?
Let me know how you get on in the next.
The ETH PHY demo modified for Olimex is in the pipe-
if you want to link CAN with LAN and LAN with CAN, also many websocket
or later WiFi to LAN or LAN to WiFi or BT to LAN ......(bla bla bla )
PR is done.
in the meantime
have phun!
best wishes
rudi
Hope you get as far as you can - just write when something goes wrong.
If the problem is for you solved feel free to edit on your first post title to [solved]
btw have read in your post from Websockets..
Then we go on with next steps with ETH PHY - LAN ?
Let me know how you get on in the next.
The ETH PHY demo modified for Olimex is in the pipe-
if you want to link CAN with LAN and LAN with CAN, also many websocket
or later WiFi to LAN or LAN to WiFi or BT to LAN ......(bla bla bla )
PR is done.
in the meantime
have phun!
best wishes
rudi
-------------------------------------
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
love it, change it or leave it.
-------------------------------------
問候飛出去的朋友遍全球魯迪
Who is online
Users browsing this forum: No registered users and 67 guests