You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ac...@apache.org on 2021/08/31 17:47:48 UTC
[incubator-nuttx] branch master updated (fd3b87e -> e180f32)
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.
from fd3b87e boards: author: Gregory Nutt: update licenses to Apache
new 1ec0258 arch/arm/src/imxrt/imxrt_flexcan.c: use SW control to check free MBs
new e180f32 boards/arm/imxrt/teensy-4.x: add option to have CAN3 as can0
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
arch/arm/src/imxrt/imxrt_flexcan.c | 58 ++++++----------------
boards/arm/imxrt/teensy-4.x/Kconfig | 6 +++
.../imxrt/teensy-4.x/configs/pikron-bb/defconfig | 15 +++---
boards/arm/imxrt/teensy-4.x/src/imxrt_flexcan.c | 17 ++++++-
4 files changed, 45 insertions(+), 51 deletions(-)
[incubator-nuttx] 01/02: arch/arm/src/imxrt/imxrt_flexcan.c: use SW
control to check free MBs
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 1ec0258407851a522d1fb21ba34988cdac18e14b
Author: Michal Lenc <mi...@seznam.cz>
AuthorDate: Sun Aug 29 22:13:18 2021 +0200
arch/arm/src/imxrt/imxrt_flexcan.c: use SW control to check free MBs
CAN_ESR2 register was having problems of havng the correct values when
the bus was busy (with 3 and more nods). The register bit fields were
incorrectly indicating that there is no free MB and would not updated
itself from this state which was causing the applications to freeze on
write. This change relies only on a software control which should avoid
the problems described above.
Signed-off-by: Michal Lenc <mi...@seznam.cz>
---
arch/arm/src/imxrt/imxrt_flexcan.c | 58 +++++++++++---------------------------
1 file changed, 16 insertions(+), 42 deletions(-)
diff --git a/arch/arm/src/imxrt/imxrt_flexcan.c b/arch/arm/src/imxrt/imxrt_flexcan.c
index 7f7d526..cdb76b1 100644
--- a/arch/arm/src/imxrt/imxrt_flexcan.c
+++ b/arch/arm/src/imxrt/imxrt_flexcan.c
@@ -470,9 +470,6 @@ static void imxrt_setfreeze(uint32_t base, uint32_t freeze);
static uint32_t imxrt_waitmcr_change(uint32_t base,
uint32_t mask,
uint32_t target_state);
-static uint32_t imxrt_waitesr2_change(uint32_t base,
- uint32_t mask,
- uint32_t target_state);
static struct mb_s *flexcan_get_mb(FAR struct imxrt_driver_s *priv,
uint32_t mbi);
@@ -531,10 +528,10 @@ static void imxrt_reset(struct imxrt_driver_s *priv);
static bool imxrt_txringfull(FAR struct imxrt_driver_s *priv)
{
- uint32_t mbi = RXMBCOUNT;
+ uint32_t mbi = RXMBCOUNT + 1;
struct mb_s *mb;
- while (mbi < TXMBCOUNT)
+ while (mbi < TOTALMBCOUNT)
{
mb = flexcan_get_mb(priv, mbi);
if (mb->cs.code != CAN_TXMB_DATAORREMOTE)
@@ -583,18 +580,13 @@ static int imxrt_transmit(FAR struct imxrt_driver_s *priv)
int32_t timeout;
#endif
- if ((getreg32(priv->base + IMXRT_CAN_ESR2_OFFSET) &
- (CAN_ESR2_IMB | CAN_ESR2_VPS)) ==
- (CAN_ESR2_IMB | CAN_ESR2_VPS))
- {
- mbi = ((getreg32(priv->base + IMXRT_CAN_ESR2_OFFSET) &
- CAN_ESR2_LPTM_MASK) >> CAN_ESR2_LPTM_SHIFT);
- }
-
+ mbi = RXMBCOUNT + 1;
mb_bit = 1 << mbi;
while (mbi < TOTALMBCOUNT)
{
+ /* Check whether message buffer is not currently transmitting */
+
struct mb_s *mb = flexcan_get_mb(priv, mbi);
if (mb->cs.code != CAN_TXMB_DATAORREMOTE)
{
@@ -771,11 +763,14 @@ static int imxrt_txpoll(struct net_driver_s *dev)
{
FAR struct imxrt_driver_s *priv =
(FAR struct imxrt_driver_s *)dev->d_private;
+ irqstate_t flags;
/* If the polling resulted in data that should be sent out on the network,
* the field d_len is set to a value > 0.
*/
+ flags = spin_lock_irqsave(NULL);
+
if (priv->dev.d_len > 0)
{
if (!devif_loopback(&priv->dev))
@@ -790,15 +785,16 @@ static int imxrt_txpoll(struct net_driver_s *dev)
* not, return a non-zero value to terminate the poll.
*/
- if (!((getreg32(priv->base + IMXRT_CAN_ESR2_OFFSET) &
- (CAN_ESR2_IMB | CAN_ESR2_VPS)) ==
- (CAN_ESR2_IMB | CAN_ESR2_VPS)) || (imxrt_txringfull(priv)))
- {
- return -EBUSY;
- }
+ if (imxrt_txringfull(priv))
+ {
+ spin_unlock_irqrestore(NULL, flags);
+ return -EBUSY;
+ }
}
}
+ spin_unlock_irqrestore(NULL, flags);
+
/* If zero is returned, the polling will continue until all connections
* have been examined.
*/
@@ -1268,26 +1264,6 @@ static uint32_t imxrt_waitfreezeack_change(uint32_t base,
return imxrt_waitmcr_change(base, CAN_MCR_FRZACK, target_state);
}
-static uint32_t imxrt_waitesr2_change(uint32_t base, uint32_t mask,
- uint32_t target_state)
-{
- const uint32_t timeout = 1000;
- uint32_t wait_ack;
-
- for (wait_ack = 0; wait_ack < timeout; wait_ack++)
- {
- uint32_t state = (getreg32(base + IMXRT_CAN_ESR2_OFFSET) & mask);
- if (state == target_state)
- {
- return true;
- }
-
- up_udelay(10);
- }
-
- return false;
-}
-
static struct mb_s *flexcan_get_mb(FAR struct imxrt_driver_s *priv,
uint32_t mbi)
{
@@ -1401,9 +1377,7 @@ static void imxrt_txavail_work(FAR void *arg)
* packet.
*/
- if (imxrt_waitesr2_change(priv->base,
- (CAN_ESR2_IMB | CAN_ESR2_VPS),
- (CAN_ESR2_IMB | CAN_ESR2_VPS)))
+ if (!imxrt_txringfull(priv))
{
/* No, there is space for another transfer. Poll the network for
* new XMIT data.
[incubator-nuttx] 02/02: boards/arm/imxrt/teensy-4.x: add option to
have CAN3 as can0
Posted by ac...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit e180f3202053c3a7deea7dc7d6060097bbf29014
Author: Michal Lenc <mi...@seznam.cz>
AuthorDate: Sun Aug 29 22:59:14 2021 +0200
boards/arm/imxrt/teensy-4.x: add option to have CAN3 as can0
This commit adds option for Teensy 4.x board to initialize CAN3 as can0.
The reason of this is the CAN FD capability of CAN3. This commit also
disables tickless mode support for pikron-bb configuration as this option
started causing hard faults which are yet to be solved.
Signed-off-by: Michal Lenc <mi...@seznam.cz>
---
boards/arm/imxrt/teensy-4.x/Kconfig | 6 ++++++
boards/arm/imxrt/teensy-4.x/configs/pikron-bb/defconfig | 15 +++++++--------
boards/arm/imxrt/teensy-4.x/src/imxrt_flexcan.c | 17 ++++++++++++++++-
3 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/boards/arm/imxrt/teensy-4.x/Kconfig b/boards/arm/imxrt/teensy-4.x/Kconfig
index 9b330f6..74faef1 100644
--- a/boards/arm/imxrt/teensy-4.x/Kconfig
+++ b/boards/arm/imxrt/teensy-4.x/Kconfig
@@ -24,4 +24,10 @@ config TEENSY_41
endchoice # Board configuration
+config IMXRT_FLEXCAN3_AS_CAN0
+ bool "Initialize CAN3 bus as can0"
+ ---help---
+ This configuration option ensures that if more that one CAN bus is set on
+ that CAN 3 (with FD capability) will be initialized as can0.
+
endif
diff --git a/boards/arm/imxrt/teensy-4.x/configs/pikron-bb/defconfig b/boards/arm/imxrt/teensy-4.x/configs/pikron-bb/defconfig
index 7f2b586..fb63dba 100644
--- a/boards/arm/imxrt/teensy-4.x/configs/pikron-bb/defconfig
+++ b/boards/arm/imxrt/teensy-4.x/configs/pikron-bb/defconfig
@@ -9,6 +9,7 @@
# CONFIG_NSH_DISABLE_DATE is not set
# CONFIG_NSH_DISABLE_PRINTF is not set
# CONFIG_NSH_DISABLE_TRUNCATE is not set
+CONFIG_ALLOW_GPL_COMPONENTS=y
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="teensy-4.x"
CONFIG_ARCH_BOARD_TEENSY_4X=y
@@ -31,11 +32,6 @@ CONFIG_CANUTILS_CANDUMP=y
CONFIG_CANUTILS_CANSEND=y
CONFIG_CAN_FD=y
CONFIG_CLOCK_MONOTONIC=y
-CONFIG_DEBUG_ERROR=y
-CONFIG_DEBUG_FEATURES=y
-CONFIG_DEBUG_FULLOPT=y
-CONFIG_DEBUG_SYMBOLS=y
-CONFIG_DEBUG_WARN=y
CONFIG_DEV_LOOP=y
CONFIG_DEV_ZERO=y
CONFIG_DRIVERS_VIDEO=y
@@ -58,7 +54,11 @@ CONFIG_IDLETHREAD_STACKSIZE=2048
CONFIG_IMXRT_ENET=y
CONFIG_IMXRT_ENET_NRXBUFFERS=16
CONFIG_IMXRT_ENET_NTXBUFFERS=8
+CONFIG_IMXRT_FLEXCAN1=y
+CONFIG_IMXRT_FLEXCAN2=y
CONFIG_IMXRT_FLEXCAN3=y
+CONFIG_IMXRT_FLEXCAN3_AS_CAN0=y
+CONFIG_IMXRT_FLEXCAN_TXMB=1
CONFIG_IMXRT_LPSPI4=y
CONFIG_IMXRT_LPUART1=y
CONFIG_IMXRT_SNVS_LPSRTC=y
@@ -128,9 +128,8 @@ CONFIG_RAM_START=0x20200000
CONFIG_READLINE_CMD_HISTORY=y
CONFIG_RR_INTERVAL=10
CONFIG_SCHED_CPULOAD=y
+CONFIG_SCHED_CPULOAD_EXTCLK=y
CONFIG_SCHED_LPWORK=y
-CONFIG_SCHED_TICKLESS=y
-CONFIG_SCHED_TICKLESS_ALARM=y
CONFIG_SCHED_USER_IDENTITY=y
CONFIG_SCHED_WAITPID=y
CONFIG_SERIAL_TERMIOS=y
@@ -147,6 +146,6 @@ CONFIG_SYSTEM_PING6=y
CONFIG_SYSTEM_PING=y
CONFIG_SYSTEM_TEE=y
CONFIG_TEENSY_41=y
-CONFIG_USEC_PER_TICK=10
+CONFIG_USEC_PER_TICK=1000
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_VIDEO_FB=y
diff --git a/boards/arm/imxrt/teensy-4.x/src/imxrt_flexcan.c b/boards/arm/imxrt/teensy-4.x/src/imxrt_flexcan.c
index 8d08c46..729ce7f 100644
--- a/boards/arm/imxrt/teensy-4.x/src/imxrt_flexcan.c
+++ b/boards/arm/imxrt/teensy-4.x/src/imxrt_flexcan.c
@@ -50,6 +50,19 @@
int imxrt_can_setup(void)
{
int ret;
+
+#ifdef CONFIG_IMXRT_FLEXCAN3_AS_CAN0
+# ifdef CONFIG_IMXRT_FLEXCAN3
+ ret = imxrt_caninitialize(3);
+ if (ret < 0)
+ {
+ canerr("ERROR: Failed to get CAN interface\n");
+ return -ENODEV;
+ }
+
+# endif
+#endif
+
#ifdef CONFIG_IMXRT_FLEXCAN1
/* Call arm_caninitialize() to get an instance of the CAN interface */
@@ -70,7 +83,8 @@ int imxrt_can_setup(void)
}
#endif
-#ifdef CONFIG_IMXRT_FLEXCAN3
+#ifndef CONFIG_IMXRT_FLEXCAN3_AS_CAN0
+# ifdef CONFIG_IMXRT_FLEXCAN3
ret = imxrt_caninitialize(3);
if (ret < 0)
{
@@ -78,6 +92,7 @@ int imxrt_can_setup(void)
return -ENODEV;
}
+# endif
#endif
UNUSED(ret);
return OK;