blob: 900c870d908cc8d89531a92083424bdf5df58255 [file] [log] [blame]
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +02001/*
2 * Copyright (c) 2020 Cypress Semiconductor Corporation
Roman Okhrimenko977b3752022-03-31 14:40:48 +03003 * Copyright (c) 2021 Infineon Technologies AG
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +02004 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
Dovhal Artem (CSUKR CSS ICW SW FW 1)f7a3d1b2022-04-01 15:07:37 +00007/*
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +02008 * Licensed to the Apache Software Foundation (ASF) under one
9 * or more contributor license agreements. See the NOTICE file
10 * distributed with this work for additional information
11 * regarding copyright ownership. The ASF licenses this file
12 * to you under the Apache License, Version 2.0 (the
13 * "License"); you may not use this file except in compliance
14 * with the License. You may obtain a copy of the License at
15 *
16 * http://www.apache.org/licenses/LICENSE-2.0
17 *
18 * Unless required by applicable law or agreed to in writing,
19 * software distributed under the License is distributed on an
20 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
21 * KIND, either express or implied. See the License for the
22 * specific language governing permissions and limitations
23 * under the License.
24 */
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020025
Dovhal Artem (CSUKR CSS ICW SW FW 1)f7a3d1b2022-04-01 15:07:37 +000026#include "platform.h"
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020027
Roman Okhrimenko977b3752022-03-31 14:40:48 +030028#if !(SWAP_DISABLED) && defined(UPGRADE_IMAGE)
29#include "set_img_ok.h"
30#endif
31
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020032int main(void)
33{
Dovhal Artem (CSUKR CSS ICW SW FW 1)f7a3d1b2022-04-01 15:07:37 +000034 const char* detect_core_message = test_app_init_hardware();
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020035
36 printf(GREETING_MESSAGE_INFO);
37
Roman Okhrimenko977b3752022-03-31 14:40:48 +030038#if !(SWAP_DISABLED) && defined(UPGRADE_IMAGE)
39 int rc = -1;
Roman Okhrimenko13f79ed2021-03-11 19:05:41 +020040
41 printf("[BlinkyApp] Try to set img_ok to confirm upgrade image\r\n");
42
43 /* Write Image OK flag to the slot trailer, so MCUBoot-loader
Roman Okhrimenko977b3752022-03-31 14:40:48 +030044 * will not revert new image
45 */
46 rc = set_img_ok(IMG_OK_ADDR, USER_SWAP_IMAGE_OK);
47
48 if (IMG_OK_ALREADY_SET == rc) {
Roman Okhrimenko13f79ed2021-03-11 19:05:41 +020049 printf("[BlinkyApp] Img_ok is already set in trailer\r\n");
Dovhal Artem (CSUKR CSS ICW SW FW 1)f7a3d1b2022-04-01 15:07:37 +000050 } else if (IMG_OK_SET_SUCCESS == rc) {
Roman Okhrimenko977b3752022-03-31 14:40:48 +030051 printf("[BlinkyApp] SWAP Status : Image OK was set at 0x%08x.\r\n", IMG_OK_ADDR);
Dovhal Artem (CSUKR CSS ICW SW FW 1)f7a3d1b2022-04-01 15:07:37 +000052 } else {
Roman Okhrimenko977b3752022-03-31 14:40:48 +030053 printf("[BlinkyApp] SWAP Status : Failed to set Image OK.\r\n");
54 }
55
56#endif /* !(SWAP_DISABLED) && defined(UPGRADE_IMAGE) */
Roman Okhrimenko13f79ed2021-03-11 19:05:41 +020057
Dovhal Artem (CSUKR CSS ICW SW FW 1)f7a3d1b2022-04-01 15:07:37 +000058 printf("[BlinkyApp] Image type: " IMAGE_TYPE " on %s core\r\n", detect_core_message);
59
60 for (;;) {
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020061 /* Toggle the user LED periodically */
Dovhal Artem (CSUKR CSS ICW SW FW 1)f7a3d1b2022-04-01 15:07:37 +000062 Cy_SysLib_Delay(BLINK_PERIOD / 2);
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020063
64 /* Invert the USER LED state */
65 Cy_GPIO_Inv(LED_PORT, LED_PIN);
66 }
Roman Okhrimenko977b3752022-03-31 14:40:48 +030067
Roman Okhrimenko89ecdac2020-02-28 17:05:55 +020068 return 0;
69}