Junbo-Zheng commented on code in PR #21541:
URL: https://github.com/apache/nuttx/pull/21541#discussion_r4509914400


##########
boards/xtensa/esp32/esp32-m5-stickc-plus/src/esp32_bm8563.c:
##########
@@ -0,0 +1,98 @@
+/****************************************************************************
+ * boards/xtensa/esp32/esp32-m5-stickc-plus/src/esp32_bm8563.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <errno.h>
+#include <syslog.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/clock.h>
+#include <nuttx/i2c/i2c_master.h>
+#include <nuttx/timers/pcf8563.h>
+
+#include "esp32_i2c.h"
+#include "esp32-m5-stickc-plus.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: up_rtc_initialize
+ *
+ * Description:
+ *   clock_initialize() always calls up_rtc_initialize() when CONFIG_RTC is
+ *   set.  On ESP32 that function only exists in the internal RTC driver,
+ *   which is not built when the system time comes from the external BM8563
+ *   instead.  There is no internal RTC hardware to set up in that case; the
+ *   BM8563 itself is brought up later from board_bm8563_initialize(), once
+ *   the I2C bus is available.
+ *
+ ****************************************************************************/
+
+#ifndef CONFIG_RTC_DRIVER
+int up_rtc_initialize(void)

Review Comment:
   > yes, but you can enable CONFIG_RTC_EXTERNAL to skip the early 
up_rtc_initialize
   
   CONFIG_RTC_EXTERNAL is already enabled in the defconfig. However, it does 
not skip the early up_rtc_initialize() call: clock_initialize() invokes it 
unconditionally whenever CONFIG_RTC=y (sched/clock/clock_initialize.c) — 
CONFIG_RTC_EXTERNAL only skips the clock_inittime() call there.
   
https://github.com/apache/nuttx/blob/master/sched/clock/clock_initialize.c#L204-L237
   
   The Kconfig help text for RTC_EXTERNAL does say it "suppresses attempts to 
initialize the RTC early in the boot sequence", but the code does not actually 
do that for up_rtc_initialize(). So the stub is still needed to satisfy the 
link (the ESP32 arch only provides this symbol under CONFIG_RTC_DRIVER, which 
conflicts with the PCF8563 driver here).
   
   So the code currently diverges from the documented behavior — should 
clock_initialize() also skip up_rtc_initialize() when CONFIG_RTC_EXTERNAL is 
set? I can send a separate PR for it.  



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to