Skip to content

Commit

Permalink
Fixed rtc problem and optimize document description
Browse files Browse the repository at this point in the history
  • Loading branch information
kurisaW authored and Rbb666 committed Dec 19, 2024
1 parent f2abb48 commit 5f37d86
Show file tree
Hide file tree
Showing 59 changed files with 639 additions and 79 deletions.
Binary file modified docs/EtherKit_User_Manual.pdf
Binary file not shown.
116 changes: 115 additions & 1 deletion projects/etherkit_ethercat_eoe/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,86 @@ Set the Ethernet interrupt callback to: `user_ether0_callback`

Finally, click Generate Project Content to generate the underlying driver source code.

## Build Configuration

1. **Modify SConscript**: Navigate to the project and locate the file at the specified path: `.\rzn\SConscript`. Replace the file content with the following:

```python
Import('RTT_ROOT')
Import('rtconfig')
from building import *
from gcc import *

cwd = GetCurrentDir()
src = []
group = []
CPPPATH = []

if rtconfig.PLATFORM in ['iccarm']:
Return('group')
elif rtconfig.PLATFORM in GetGCCLikePLATFORM():
if GetOption('target') != 'mdk5':
src += Glob('./fsp/src/bsp/mcu/all/*.c')
src += Glob('./fsp/src/bsp/mcu/all/cr/*.c')
src += Glob('./fsp/src/bsp/mcu/r*/*.c')
src += Glob('./fsp/src/bsp/cmsis/Device/RENESAS/Source/*.c')
src += Glob('./fsp/src/bsp/cmsis/Device/RENESAS/Source/cr/*.c')
src += Glob('./fsp/src/r_*/*.c')
CPPPATH = [ cwd + '/arm/CMSIS_5/CMSIS/Core_R/Include',
cwd + '/fsp/inc',
cwd + '/fsp/inc/api',
cwd + '/fsp/inc/instances',]

if GetDepend('BSP_USING_ETHERCAT_EOE'):
src += Glob('./fsp/src/rm_ethercat_ssc_port/*.c')
CPPPATH += [cwd + '/fsp/src/rm_ethercat_ssc_port']

group = DefineGroup('rzn', src, depend = [''], CPPPATH = CPPPATH)
Return('group')
```

2. **Modify Kconfig**: Open the file located at `projects\etherkit_ethercat_eoe\board\Kconfig`. Add the EOE configuration under the *Onboard Peripheral Drivers* section:

```c
config BSP_USING_ETHERCAT_EOE
bool "Enable EtherCAT EOE example"
select BSP_USING_ETH
default n
if BSP_USING_ETHERCAT_EOE
config RT_LWIP_IPADDR
string "set static ip address for eoe slaver"
default "192.168.10.100"
config RT_LWIP_GWADDR
string "set static gateway address for eoe slaver"
default "192.168.10.1"
config RT_LWIP_MSKADDR
string "set static mask address for eoe slaver"
default "255.255.255.0"
endif
```

As shown in the following figure:

![image-20241216133719165](figures/image-20241216133719165.png)

3. **Development Environment**:
- If you are using Studio for development, right-click the project and select **Sync SCons Configuration to Project**.
- If you are using IAR for development, right-click in the current project directory to open the environment and execute:
```bash
scons --target=iar
```
to regenerate the configuration.

## RT-Thread Studio Configuration

After completing the FSP configuration, pin and peripheral initialization is done. Now, we need to enable the EtherCAT EOE example. Open Studio, click RT-Thread Settings, and enable the EOE example:

![image-20241126113041985](figures/image-20241126113041985.png)

Next, we need to configure the system to disable DHCP and use a static IP. Click on the component -> enable the lwip stack, and select to disable DHCP:

![image-20241213114404172](figures/image-20241213114404172.png)

Once enabled, save the settings and synchronize the scons configuration. Then compile and download the program. After resetting the development board, observe the serial log:

![image-20241126175253263](figures/image-20241126175253263.png)
Expand Down Expand Up @@ -190,4 +264,44 @@ At this point, you can use DHCP to configure an automatic IP or manually assign
![image-20241126113612960](figures/image-20241126113612960.png)
Once configured, the EOE App will work, allowing communication over EtherCAT!
Once configured, the EOE App will work, allowing communication over EtherCAT!
## Extension Explanation: 3-Port Ethernet EOE Communication
The example project currently defaults to a 2-port Ethernet EOE configuration. If you need to use a 3-port EOE communication setup, please follow the instructions in this chapter for configuration.
### FSP Configuration
First, open the FSP configuration file in the project. We will add a third PHY for the SSC stack.
![image-20241217181157005](figures/image-20241217181157005.png)
Next, configure the channel count for PHY2 to 2, and set the PHY address to 3 (as referenced from the schematic manual). Also, configure the network card model as user-defined and set the Ethernet initialization callback function.
![image-20241217181209037](figures/image-20241217181209037.png)
Then, configure the pins to enable ETH2.
![image-20241217181218646](figures/image-20241217181218646.png)
Next, configure the ESC corresponding to the ETH2 LINK pins, setting ESC_LINKACT2 (P22_1) and ESC_PHYLINK2 (P00_5). Note: **If P22_1 is already in use, you must first manually disable its multiplexing function before enabling this option**.
![image-20241217181235776](figures/image-20241217181235776.png)
After completing the above configurations, you can click to generate the source code, return to the project, compile it, and download the program to the development board.
### ESI Firmware Update
Similarly, we need to wait for the development board's EOE slave to successfully run. Then, open the TwinCAT 3 software to scan for devices. Once the EtherCAT device is found, do not activate it immediately. In the pop-up window, click "No."
![image-20241217181259080](figures/image-20241217181259080.png)
Refer to the **"Update EEPROM Firmware"** section. Follow the same steps, but this time, select the firmware to be updated as: Renesas EtherCAT RZ/N2 EoE 3port [2308 / 768], and click to flash the firmware.
![image-20241217181338720](figures/image-20241217181338720.png)
Once the flashing is complete, we need to delete the device again and scan it once more. You should see that the slave device description has been updated to "Box 1 (Renesas EtherCAT RZ/N2 EoE 3port)."
![image-20241217181350020](figures/image-20241217181350020.png)
For further EOE development, please refer to the previous chapters.
110 changes: 109 additions & 1 deletion projects/etherkit_ethercat_eoe/README_zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,12 +122,80 @@ ethernet中断触发回调设置为:user_ether0_callback

最后点击Generate Project Content生成底层驱动源码。

## 构建配置

1. 修改sconscript:进入工程找到指定路径下的文件:.\rzn\SConscript,替换该文件为如下内容:

```c
Import('RTT_ROOT')
Import('rtconfig')
from building import *
from gcc import *

cwd = GetCurrentDir()
src = []
group = []
CPPPATH = []

if rtconfig.PLATFORM in ['iccarm']:
Return('group')
elif rtconfig.PLATFORM in GetGCCLikePLATFORM():
if GetOption('target') != 'mdk5':
src += Glob('./fsp/src/bsp/mcu/all/*.c')
src += Glob('./fsp/src/bsp/mcu/all/cr/*.c')
src += Glob('./fsp/src/bsp/mcu/r*/*.c')
src += Glob('./fsp/src/bsp/cmsis/Device/RENESAS/Source/*.c')
src += Glob('./fsp/src/bsp/cmsis/Device/RENESAS/Source/cr/*.c')
src += Glob('./fsp/src/r_*/*.c')
CPPPATH = [ cwd + '/arm/CMSIS_5/CMSIS/Core_R/Include',
cwd + '/fsp/inc',
cwd + '/fsp/inc/api',
cwd + '/fsp/inc/instances',]

if GetDepend('BSP_USING_ETHERCAT_EOE'):
src += Glob('./fsp/src/rm_ethercat_ssc_port/*.c')
CPPPATH += [cwd + '/fsp/src/rm_ethercat_ssc_port']

group = DefineGroup('rzn', src, depend = [''], CPPPATH = CPPPATH)
Return('group')
```
2. Kconfig修改:打开工程下的文件(projects\etherkit_ethercat_eoe\board\Kconfig),在Onboard Peripheral Drivers选项中加入EOE配置:
```c
config BSP_USING_ETHERCAT_EOE
bool "Enable EtherCAT EOE example"
select BSP_USING_ETH
default n
if BSP_USING_ETHERCAT_EOE
config RT_LWIP_IPADDR
string "set static ip address for eoe slaver"
default "192.168.10.100"
config RT_LWIP_GWADDR
string "set static gateway address for eoe slaver"
default "192.168.10.1"
config RT_LWIP_MSKADDR
string "set static mask address for eoe slaver"
default "255.255.255.0"
endif
```

如下图所示:

![image-20241216133719165](figures/image-20241216133719165.png)

3. 使用studio开发的话需要右键工程点击 **同步scons配置至项目**;如果是使用IAR开发请在当前工程下右键打开env,执行:scons –target=iar 重新生成配置。

## RT-Thread Studio配置

完成FSP配置之后,引脚及外设的初始化就暂告一段落了,接下来需要我们使能EtherCAT EOE示例,打开Studio,点击 RT-Thread Settings,使能EOE示例:

![image-20241126113041985](figures/image-20241126113041985.png)

下面我们还需要配置禁用dhcp功能并使用静态IP,点击组件->使能lwip堆栈,选择禁用DHCP;

![image-20241213114304739](figures/image-20241213114304739.png)

使能完毕后我们保存settings配置并同步scons配置,同时编译并下载程序,复位开发板后观察串口日志:

![image-20241126175253263](figures/image-20241126175253263.png)
Expand Down Expand Up @@ -211,4 +279,44 @@ ethernet中断触发回调设置为:user_ether0_callback
* 主站IP:192.168.10.99
* 从站IP:192.168.10.100

![image-20241126113612960](figures/image-20241126113612960.png)
![image-20241126113612960](figures/image-20241126113612960.png)

## 拓展说明:3端口以太网EOE通信

目前示例工程默认为2端口以太网EOE,如需使用三网口EOE通信请遵循本章说明进行配置;

### FSP配置

首先仍然是打开工程下的FSP配置文件,我们为SSC stack添加第三个phy;

![image-20241217181157005](figures/image-20241217181157005.png)

然后配置phy2的通道数为2,phy address为3(根据原理图手册查询可知),同时配置网卡型号为用户自定义,并且设置以太网初始化回调函数;

![image-20241217181209037](figures/image-20241217181209037.png)

接下来配置引脚,使能ETH2;

![image-20241217181218646](figures/image-20241217181218646.png)

接着我们配置ESC对应ETH2的LINK引脚,分别配置ESC_LINKACT2(P22_1)和ESC_PHYLINK2(P00_5);此处需要注意:**此处如果P22_1被占用,需要先手动将该引脚复用功能禁用后,再使能此项**

![image-20241217181235776](figures/image-20241217181235776.png)

完成上述配置后就可以点击生成源码了,回到工程编译并将程序下载开发板中;

### ESI固件更新

同样首先我们需要等待开发板EOE从站成功运行,接着我们打开TwinCAT 3软件扫描设备,扫描到EtherCAT设备后先暂时不激活,弹窗点击否即可;

![image-20241217181259080](figures/image-20241217181259080.png)

参考**“更新EEPROM固件”**一节,一样的步骤,只不过这次需要选择更新的固件为:Renesas EtherCAT RZ/N2 EoE 3port [2308 / 768],点击烧录固件;

![image-20241217181338720](figures/image-20241217181338720.png)

烧录完成后我们需要重新删除设备并再次扫描,可以看到从站设备描述已经更新为Box 1 (Renesas EtherCAT RZ/N2 EoE 3port);

![image-20241217181350020](figures/image-20241217181350020.png)

后续EOE开发请参考前几章节。
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 5f37d86

Please sign in to comment.