system api: Refactor to esp_common, small fixes Closes IDFGH-2096 See merge request espressif/esp-idf!6544