Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2020 Cypress Semiconductor Corporation |
Roman Okhrimenko | 977b375 | 2022-03-31 14:40:48 +0300 | [diff] [blame] | 3 | * Copyright (c) 2021 Infineon Technologies AG |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 4 | * |
| 5 | * SPDX-License-Identifier: Apache-2.0 |
| 6 | */ |
Dovhal Artem (CSUKR CSS ICW SW FW 1) | f7a3d1b | 2022-04-01 15:07:37 +0000 | [diff] [blame^] | 7 | /* |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 8 | * 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 Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 25 | |
Dovhal Artem (CSUKR CSS ICW SW FW 1) | f7a3d1b | 2022-04-01 15:07:37 +0000 | [diff] [blame^] | 26 | #include "platform.h" |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 27 | |
Roman Okhrimenko | 977b375 | 2022-03-31 14:40:48 +0300 | [diff] [blame] | 28 | #if !(SWAP_DISABLED) && defined(UPGRADE_IMAGE) |
| 29 | #include "set_img_ok.h" |
| 30 | #endif |
| 31 | |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 32 | int main(void) |
| 33 | { |
Dovhal Artem (CSUKR CSS ICW SW FW 1) | f7a3d1b | 2022-04-01 15:07:37 +0000 | [diff] [blame^] | 34 | const char* detect_core_message = test_app_init_hardware(); |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 35 | |
| 36 | printf(GREETING_MESSAGE_INFO); |
| 37 | |
Roman Okhrimenko | 977b375 | 2022-03-31 14:40:48 +0300 | [diff] [blame] | 38 | #if !(SWAP_DISABLED) && defined(UPGRADE_IMAGE) |
| 39 | int rc = -1; |
Roman Okhrimenko | 13f79ed | 2021-03-11 19:05:41 +0200 | [diff] [blame] | 40 | |
| 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 Okhrimenko | 977b375 | 2022-03-31 14:40:48 +0300 | [diff] [blame] | 44 | * 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 Okhrimenko | 13f79ed | 2021-03-11 19:05:41 +0200 | [diff] [blame] | 49 | printf("[BlinkyApp] Img_ok is already set in trailer\r\n"); |
Dovhal Artem (CSUKR CSS ICW SW FW 1) | f7a3d1b | 2022-04-01 15:07:37 +0000 | [diff] [blame^] | 50 | } else if (IMG_OK_SET_SUCCESS == rc) { |
Roman Okhrimenko | 977b375 | 2022-03-31 14:40:48 +0300 | [diff] [blame] | 51 | printf("[BlinkyApp] SWAP Status : Image OK was set at 0x%08x.\r\n", IMG_OK_ADDR); |
Dovhal Artem (CSUKR CSS ICW SW FW 1) | f7a3d1b | 2022-04-01 15:07:37 +0000 | [diff] [blame^] | 52 | } else { |
Roman Okhrimenko | 977b375 | 2022-03-31 14:40:48 +0300 | [diff] [blame] | 53 | printf("[BlinkyApp] SWAP Status : Failed to set Image OK.\r\n"); |
| 54 | } |
| 55 | |
| 56 | #endif /* !(SWAP_DISABLED) && defined(UPGRADE_IMAGE) */ |
Roman Okhrimenko | 13f79ed | 2021-03-11 19:05:41 +0200 | [diff] [blame] | 57 | |
Dovhal Artem (CSUKR CSS ICW SW FW 1) | f7a3d1b | 2022-04-01 15:07:37 +0000 | [diff] [blame^] | 58 | printf("[BlinkyApp] Image type: " IMAGE_TYPE " on %s core\r\n", detect_core_message); |
| 59 | |
| 60 | for (;;) { |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 61 | /* Toggle the user LED periodically */ |
Dovhal Artem (CSUKR CSS ICW SW FW 1) | f7a3d1b | 2022-04-01 15:07:37 +0000 | [diff] [blame^] | 62 | Cy_SysLib_Delay(BLINK_PERIOD / 2); |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 63 | |
| 64 | /* Invert the USER LED state */ |
| 65 | Cy_GPIO_Inv(LED_PORT, LED_PIN); |
| 66 | } |
Roman Okhrimenko | 977b375 | 2022-03-31 14:40:48 +0300 | [diff] [blame] | 67 | |
Roman Okhrimenko | 89ecdac | 2020-02-28 17:05:55 +0200 | [diff] [blame] | 68 | return 0; |
| 69 | } |